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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call stored procedure

Status
Not open for further replies.

sexydog

Programmer
Jul 9, 2002
176
0
0
GB
how do i call and use a stored procedure in vb6
 
Hi,

I'm assuming that you are using ADO and SQL or similar here.

If the stored procedure has no arguments then you can just use the .Execute method of the ADO connection,

Connection.Execute "sp_StoredProcedure"

If the stored procedure has arguments then you can either use the .Execute method again passing the arguments as part of the string,

Connection.Execute "sp_StoredProcedure 'Arg1','Arg2'"

or you can use the Command object to create the command plus the arguments. You will have to use the Command object if the stored procedure returns values through the argument list (output arguments).

Hope this helps.
Andy.
 
try this:


Dim objConn As New ADODB.Connection
Dim objCommand As New ADODB.Command
Dim strConnString As String

strConnString = "Provider..." 'connection string to your DB

objConn.ConnectionString = strConnString
objConn.Open

objCommand.ActiveConnection = objConn
objCommand.CommandType = adCmdStoredProc
objCommand.CommandText = "myStoredProc" 'your stored proc

objCommand.Execute

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top