multiple parameters with ADO and SQL Server 2000 Stored proc 
Author Message
 multiple parameters with ADO and SQL Server 2000 Stored proc

I need to pass multiple parameters to a SQL2000 stored procedure. One
parameter needs to be an integer.

I am executing the stored procedure via:
oConn.Execute "EXECUTE " & cStoredProc & CStr(lParam1) & ", '" & cParam2 &
"'"

How can I pass these correctly. SQL server raises an error about the wrong
data type being passed for the first parameter because it is expecting an
integer.

Thanks.

Tommy



Wed, 06 Jul 2005 00:58:44 GMT  
 multiple parameters with ADO and SQL Server 2000 Stored proc
I figured it out.


Quote:
> I need to pass multiple parameters to a SQL2000 stored procedure. One
> parameter needs to be an integer.

> I am executing the stored procedure via:
> oConn.Execute "EXECUTE " & cStoredProc & CStr(lParam1) & ", '" & cParam2 &
> "'"

> How can I pass these correctly. SQL server raises an error about the wrong
> data type being passed for the first parameter because it is expecting an
> integer.

> Thanks.

> Tommy



Wed, 06 Jul 2005 02:36:46 GMT  
 multiple parameters with ADO and SQL Server 2000 Stored proc

Hi Tommy.

You can use a command and create parameters.
Sample code:

Dim comDemo As ADODB.Command

'Call Stored Procedure inside SQL-Servercommandobject
Set comDemo = New ADODB.Command
With comDemo
  .ActiveConnection = cnDemo
  .CommandType = adCmdStoredProc
  .CommandText = "Demo" 'This is the SP name
  .Parameters.Append comGreefa.CreateParameter"ArtNr",
       adVarChar, adParamInput, 40, strArtNr)
  .Parameters.Append comGreefa.CreateParameter("RecSoort",
       adInteger, adParamInput, 2, RecSoort)
  .Parameters.Append comGreefa.CreateParameter("strXML",
       adVarBinary, adParamInput, UBound(oXml) + 1, oXml)
  .Execute
End With

You can define as many parameters as you like. It has to
be in the same order as your SP.

Succes.

Geert



Fri, 08 Jul 2005 21:14:35 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. know anything about Stored Proc and using SQL Server 2000, CR8.5 and VB6.0

2. Memory Full While Trying to Connect To SQL Server 2000 Stored Proc With OLEDB

3. Datetime Parameter to SQL Server stored proc

4. Help - Using Sql Server Stored Proc with parameters

5. VB.NET,SQL SERVER 2000 STORED PROCEDURE PARAMETERS, CRYSTAL REPORTS

6. Stored Proc Return values / Output Params w ADO and SQL Server 7

7. Stored Proc Return values / Output Params w ADO and SQL Server 7

8. Stored Proc Return values / Output Params w ADO and SQL Server 7

9. Stored Proc Return values / Output Params w ADO and SQL Server 7

10. How to store images using ADO in SQL Server 2000

11. Problem opening recordset for update ADO 2.1/Jet 4.0/Access 2000 stored proc

12. Multiple selections in a parameter - SQL Server stored procedure

 

 
Powered by phpBB® Forum Software