MySQL Forums
Forum List  »  Stored Procedures

return an output parameter in visual basic
Posted by: Christopher Aguilar
Date: January 30, 2006 12:47AM

Hi guys,

I am stuck with my codes with this problem. I have my stored procedure that has 2 parameters on it, one input and one output. I call it in my visual basic 6 application using CommandType = adCmdText because adCmdStoredProc has an error. There's no problem with my code if my parameters are all input. My question is how to call a stored procedure that has an output parameter? Here is my codes:

'Declare database objects
Dim objConn As New ADODB.Connection
Dim objCmd As New ADODB.Command

'Establish a database connection using NT Authentication
objConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=myserver;" _
& "DATABASE=db_mydatabase;" _
& "UID=root;" _
& "PWD=mypassword;" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
objConn.Open

'Check the state of the connection to ensure we are connected
If objConn.State = adStateOpen Then

'Set the Command object properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = "CALL sp_param_and_return(?,?);"
objCmd.CommandType = adCmdText

'Set the Command object parameters
objCmd.Parameters.Append _
objCmd.CreateParameter("ID", adVarWChar, adParamInput, 20, "txtID")

objCmd.Parameters.Append _
objCmd.CreateParameter("RowCount", adInteger, adParamOutput)

'Execute the Command object
objCmd.Execute

Chris



Edited 1 time(s). Last edit at 01/30/2006 07:32AM by Christopher Aguilar.

Options: ReplyQuote


Subject
Views
Written By
Posted
return an output parameter in visual basic
2466
January 30, 2006 12:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.