Article ID: 183059
Article Last Modified on 3/2/2005
When using the Refresh method on a Command object's Parameters Collection for retrieving provider-side parameter information of a stored procedure, parameter information may not be correct. For example, if a stored procedure is specified in the CommandText property along with a parameter, and the parameter type is a SQL Server Text type, you will not get the correct ActiveX Data Objects (ADO) type returned for that parameter.
Dim cmd As New ADODB.Command Dim rs As New ADODB.Recordset Dim param1 As Parameter Dim strValue As String cmd.ActiveConnection = "DSN=SQLServer;Username=<username>;PWD=<strong password>;Database=pubs" cmd.CommandText = "sp_procedure1" cmd.CommandType = adCmdStoredProc ' Calling Refresh method to retrieve the parameters information. cmd.Parameters.Refresh ' Setting the value of the parameter to a string > 255 characters. strValue = String(260, "A") ' Set the parameter value to be passed. cmd.Parameters(1).Value = strValue Set RS = cmd.Execute
CREATE TABLE Table1(field1 Text) CREATE PROC sp_procedure1 @param1 TEXT as INSERT INTO Table1 VALUES(@param1)
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim param1 As Parameter
Dim strValue As String
cmd.ActiveConnection = "DSN=SQLServer;Username=<username>;PWD=<strong password>;Database=Pubs"
cmd.CommandText = "{call sp_procedure1 (?)}"
cmd.CommandType = adCmdText
' Calling Refresh method to retrieve the parameters information.
cmd.Parameters.Refresh
strValue = String(260, "A")
' Set the parameter value to be passed.
cmd.Parameters(0).Value = strValue
Set RS = cmd.Execute
174223 HOWTO: Refresh ADO Parameters Collection for a Stored Procedure
Keywords: kbstoredproc kbmdac250fix kbdatabase kbprb kbmdacnosweep kbarttypeinf KB183059