all groups > sql server programming > november 2005 >
You're in the

sql server programming

group:

UPDATE SP works in QA but not in VB


UPDATE SP works in QA but not in VB Mark Hoffy
11/5/2005 4:03:04 PM
sql server programming: Hello,

I have a stored proc that works when I run it in query anlalyzer, but
returns an error when called from code. Do I need to make some change to
the query to make it callable? Thanks for any help.

SP:

create proc udpCombine
@comb varchar (10),
@keep varchar (10)
AS
--perform updates
UPDATE tblFS SET FSChart=@keep WHERE FSChart=@comb
UPDATE tblCI SET CIChart=@keep WHERE CIChart=@comb
UPDATE tblPay SET PayChart=@keep WHERE PayChart=@comb
--delete the source
DELETE FROM tblCH WHERE CHChart=@comb
go

QA has no problems with it, but when I call it from app, I get:

Line 1: Incorrect syntax near 'udpCombine'.

I am calling with:

cmdSQL = New SqlCommand("udpCombine", cCom)
cmdSQL.Parameters.Add("@comb", SqlDbType.VarChar).Value = lblCombine.Text

cmdSQL.Parameters.Add("@keep", SqlDbType.VarChar).Value = lblKeep.Text

Try

cmdSQL.ExecuteNonQuery()

Catch exSQL As SqlException

MsgBox("SQL Exception in cmdCombine." & vbCrLf & vbCrLf & exSQL.Message,
MsgBoxStyle.Exclamation, g_sProgram)

End Try



Re: UPDATE SP works in QA but not in VB Erland Sommarskog
11/5/2005 11:41:59 PM
Mark Hoffy (mark@here.com) writes:
[quoted text, click to view]

You need to specify

cmdSQL.CommandType = CommandType.StoredProcedure

Else you get a command-text batch.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Re: UPDATE SP works in QA but not in VB Mark Hoffy
11/6/2005 5:03:22 AM
Oh man - thanks Erland. I kept looking at the SP, didnt even recheck that
part of my code. Sorry for the bother.

Mark

[quoted text, click to view]

AddThis Social Bookmark Button