How do you execute a stored procedure from VB using ADO?
Posted in 2000
I am writing an application in VB6 using ADO. The app needs to execute a stored procedure in the Server. The procedure accepts two parameters, a string and a integer. The Server is a SUN running Informix 7.3. Following the examples from MSDN I have developed the following code. Public Function StrPscd(ThisPnCdId As Long) As Long Dim cmdStrPscd As ADODB.Command Dim Parm0 As ADODB.Parameters Dim Parm1 As ADODB.Parameters Dim rsPscd As ADODB.Recordset Dim vSntPscd As Variant Dim vStrPscd As Variant Dim ThisPscd As String Dim vRslt As Variant StrPscd = 1 'get the passcode from A Sql_QryS = "select pin_code from pin_codes where pin_code_id = " & ThisPnCdId If GetRcrdStS(vSntPscd, 1) Then 'This gets a recordset & stores it in vSntPscd 'now store it in CRS ThisPscd = Trim(vSntPscd(0, 0)) Set cmdStrPscd = New ADODB.Command With cmdStrPscd .ActiveConnection = cnC .CommandType = adCmdStoredProc .CommandText = "ispinvalid" .CommandTimeout = 15 End With cmdStrPscd(0) = ThisPscd ** [Informix ODBC Driver] "A syntax error has occurred" cmdStrPscd(1) = 2 'operator id for migration Set vStrPscd = cmdStrPscd.Execute If vStrPscd.Fields(0) = 0 Then If vStrPscd.Fields(1) = 1 Then Else at the cmdStrPscd(0) = ThisPscd I get the message "A syntax error has occurred". This is my first experience with stored procedures so my apologies for the probably obvious error. Thanks for your help in advance John