Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

store procedure from SQLServer and Visual Basic

Status
Not open for further replies.

oigo

Programmer
Apr 27, 2002
23
CO
Hello, I get a applicaction in VB6, my DB in SQLServer 2000, I need to execute a store procedure in the Server, it returns parameters output, how can I get those parameters in my app VB?

Thanks
 

use the recordset object of ADO to execute your stored proceedure and return your records.
 
Below is the code I use to pass parameters to a stored procedure and get the resulting recordset.


Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command

With cmd
.ActiveConnection = m_Conn 'defined and set at form level.
.CommandText = "StoredProcedureName"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("Param", adInteger, adParamInput)
.Parameters(&quot;Param&quot;).Value = <variable>
End With
rs.Open cmd, , adOpenStatic, adLockOptimistic

&quot;StoredProcedureName&quot; is the name of my stored procedure.
&quot;Param&quot; is the name of my parameter in the stored procedure (@Param). Add as many parameters as you require in the same order as they appear in the stored procedure.

Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top