get a return from a SP?

  • Thread starter Thread starter __Stephen
  • Start date Start date
S

__Stephen

I have an SP with an output param

This code works fine in T-SQL
declare @ret varchar(8)
exec dbo.spProcessSecurity 'L\M{¢!AA', @ret OUTPUT
--print @ret

How do I grab the @ret in vb(6) ?

TIA
 
__Stephen said:
I have an SP with an output param

This code works fine in T-SQL
declare @ret varchar(8)
exec dbo.spProcessSecurity 'L\M{¢!AA', @ret OUTPUT
--print @ret

How do I grab the @ret in vb(6) ?

TIA

WARNING!! UNTESTED CODE!!

Dim cn As New rdoConnection
Dim rst As New rdoConnection
Dim sConnect As String
Dim sSQL As String
Dim qry As rdoQuery

sConnect = "UID=sa;PWD=blah;Database=msdb;Server=server1;Driver={SQL
Server};DSN='';"
With cn
.Connect = sConnect
.LoginTimeout = 0
.CursorDriver = rdUseOdbc
.QueryTimeout = 0
.EstablishConnection rdDriverNoPrompt
End With

sSQL = "{ ? = call sp_storedprocname (?, ?, ?, ?, ?, ?) }"
Set qry = cn.CreateQuery("startjob", sSQL$)
qry.rdoParameters(0).Direction = rdParamReturnValue
qry(1) = "test job"
qry(5) = "no step"
qry.Execute
If qry.rdoParameters(0) <> 0 Then
MsgBox "start job returned error!"
End If
cn.Close
 
thanks.

__Stephen said:
I have an SP with an output param

This code works fine in T-SQL
declare @ret varchar(8)
exec dbo.spProcessSecurity 'L\M{¢!AA', @ret OUTPUT
--print @ret

How do I grab the @ret in vb(6) ?

TIA

WARNING!! UNTESTED CODE!!

Dim cn As New rdoConnection
Dim rst As New rdoConnection
Dim sConnect As String
Dim sSQL As String
Dim qry As rdoQuery

sConnect = "UID=sa;PWD=blah;Database=msdb;Server=server1;Driver={SQL
Server};DSN='';"
With cn
.Connect = sConnect
.LoginTimeout = 0
.CursorDriver = rdUseOdbc
.QueryTimeout = 0
.EstablishConnection rdDriverNoPrompt
End With

sSQL = "{ ? = call sp_storedprocname (?, ?, ?, ?, ?, ?) }"
Set qry = cn.CreateQuery("startjob", sSQL$)
qry.rdoParameters(0).Direction = rdParamReturnValue
qry(1) = "test job"
qry(5) = "no step"
qry.Execute
If qry.rdoParameters(0) <> 0 Then
MsgBox "start job returned error!"
End If
cn.Close
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top