
ADO Data type for SQL Server Text
There are more than one way to implement this task:
One is to query the data source about the parameters of the stored
procedure by calling the Refresh function of the parameters collection of
command object. Sample code:
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText = "sp_AdoTest"
Cmd1.CommandType = adCmdStoredProc
Cmd1.Parameters.Refresh
Cmd1.Parameters(1).Value = "text for the parameter"
Set Rs1 = Cmd1.Execute()
Another method is to explicitly create the parameter objects properties
using the CreateParameter function of the command object and Append
function of the parameters collection of the command object. Sample code:
...
Set Cmd1 = New ADODB.Command
Cmd1.ActiveConnection = Conn1
Cmd1.CommandText= "sp_AdoTest"
Set Param1 = Cmd1.CreateParameter(, adInteger, adParamReturnValue)
Cmd1.Parameters.Append Param1
Set Param2 = Cmd1.CreateParameter(, adInteger, adParamInput)
Param2.Value = 10
Cmd1.Parameters.Append Param2
Set Param3 = Cmd1.CreateParameter(, adInteger, adParamOutput)
Cmd1.Parameters.Append Param3
Set Rs1 = Cmd1.Execute()
For more formation, please refer to the following article in Microsoft
Knowledge Base:
Title:HOWTO: Refresh ADO Parameters for a Stored Procedure
http://support.microsoft.com/support/kb/articles/q174/2/23.asp