[thelist] Calling a sproc from VB

Tab Alleman Tab.Alleman at MetroGuide.com
Mon Feb 2 12:05:07 CST 2004


I'm calling a SQL2k Procedure from a VB app, and I'm not getting the
expected change in my Output parameter.  Here are some relevant code
snips:

The VB app:
Set x = CreateObject("ADODB.Connection")
x.Open "MY_CONNECTION_STRING"

Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = x
spResultStr = ""
With cmd
    .Parameters.Append cmd.CreateParameter("@ResultStr", adVarChar,
adParamOutput, 5000, spResultStr)
    .CommandText = "tsp_CURT_ImportTextFiles_dev"
    .CommandType = adCmdStoredProc
End With
iSprocReturn = cmd.Execute
--------------------------------------------

And in the sproc:
CREATE PROCEDURE dbo.tsp_CURT_ImportTextFiles_dev
	@ResultStr varchar(5000) OUTPUT
AS

SET NOCOUNT OFF

SELECT @ResultStr = 'Beginning procedure'

...
--------------------------------------------

But when I run the app, the cmd.execute runs without error, but the
spResultStr variable is empty afterwards.  It should contain the text,
"Beginning procedure".  

What am I doing wrong?

TIA,
Tab



More information about the thelist mailing list