Home All Groups Group Topic Archive Search About

UPDATE SP works in QA but not in VB

Author
5 Nov 2005 9:03 PM
Mark Hoffy
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

Author
5 Nov 2005 11:41 PM
Erland Sommarskog
Mark Hoffy (m***@here.com) writes:
> 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

You need to specify

   cmdSQL.CommandType = CommandType.StoredProcedure

Else you get a command-text batch.


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Author
6 Nov 2005 10:03 AM
Mark Hoffy
Oh man - thanks Erland.  I kept looking at the SP, didnt even recheck that
part of my code.  Sorry for the bother.

Mark

Show quote
"Erland Sommarskog" <esq***@sommarskog.se> wrote in message
news:Xns97066CCA5134Yazorman@127.0.0.1...
> Mark Hoffy (m***@here.com) writes:
> > 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
>
> You need to specify
>
>    cmdSQL.CommandType = CommandType.StoredProcedure
>
> Else you get a command-text batch.
>
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
>

AddThis Social Bookmark Button