howto get return value from stored procedure, using vb

howto get return value from stored procedure, using vb

Post by peter jun » Wed, 22 Oct 2003 16:06:04



hi i try to check with
"server.ExecuteWithResults("sp_helpreplicationdboption 'TEST1' ")" while server is an sqldmo object.
howto get the results from the stored procedure now??
please help thx

gretts peter

 
 
 

howto get return value from stored procedure, using vb

Post by BobMcClella » Wed, 22 Oct 2003 16:40:01


Received this here in this ng and worked great....

Dim cn As New ADODB.Connection
sqlString = "OrderAdder_Save"
Set oCmd = New ADODB.Command
Set cn = CurrentProject.Connection
Set oCmd.ActiveConnection = cn
oCmd.CommandText = sqlString
oCmd.CommandType = adCmdStoredProc
oCmd.CommandTimeout = 15

Set param = New ADODB.Parameter
param.Type = adChar
param.Size = 50 ' 3 bytes
param.Direction = adParamInput
param.Value = Cust
param.Name = "Cust"
oCmd.Parameters.Append param

Set param = New ADODB.Parameter
param.Type = adInteger
param.Size = 3
param.Direction = adParamOutput
param.Name = "MaxOid"
oCmd.Parameters.Append param

oCmd.Execute , , adExecuteNoRecords

x = oCmd.Parameters("MaxOid").Value


Quote:> hi i try to check with
> "server.ExecuteWithResults("sp_helpreplicationdboption 'TEST1' ")" while

server is an sqldmo object.
Quote:> howto get the results from the stored procedure now??
> please help thx

> gretts peter


 
 
 

1. Getting a return value from a SQL Server stored procedure through VB

Hey Guys,

I'm having a problem with a stored procedure in SQL Server.

This procedure is supposed to return an integer answer.  I was doing
something like this:

Dim Answer as Integer

Answer = DB.Execute(strSQL)

and I get the error (.Execute is highlighted) : Expected function or
variable

Does anybody know what I'm doing wrong here?

Thanks in advance,

Maria Turpin

2. Parsing a text file based on the caharacter ^

3. Getting the return value of a stored procedure using CRecordset

4. Surrogate keys and identity columns

5. Getting return value from Oracle Stored Procedure using ADO

6. How to get tables via SQL statement

7. returning values from stored procedures using ADO / VB code

8. Open source disk hashtable available

9. Howto get a return value from a stored procedure

10. Howto call a stored procedure and get a return value

11. Howto call a parametized stored procedure and get a return value