Microsoft KB Archive/253627

From BetaArchive Wiki
Knowledge Base


Article ID: 253627

Article Last Modified on 6/12/2001



APPLIES TO

  • Microsoft Visual InterDev 6.0 Standard Edition
  • Microsoft ActiveX Data Objects 2.0
  • Microsoft ActiveX Data Objects 2.01
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6



This article was previously published under Q253627

SYMPTOMS

When you use the Adodb.Command.Parameters.Refresh method with an Access stored query, the following error message appears:

ADODB.Command (800A0CC1) Item cannot be found in the collection corresponding to the requested name or ordinal.

CAUSE

ADODB does not support the Command.Refresh method for calling Access queries.

RESOLUTION

To work around this problem, use ActiveX Data Objects Extensions for Data Definition Language and Security (ADOX) with Catalog.Command. This will enable you to use Command.Refresh.

MORE INFORMATION

Paste the following code in a text editor, such as Microsoft Notepad, and save it as an ASP file in the \InetPub\WwwRoot folder. You can then execute this code from the browser to test the Catalog.Command.Refresh method.

NOTE: The code as provided here demonstrates the error. Refer to the comments in the code to avoid the error.

<HTML>
<BODY>
<%@ Language=VBScript %>
<!-- #INCLUDE VIRTUAL="/ADOVBS.INC" -->
<%
Dim adoConnection
Dim adoCommand
Dim adoCatalog
Dim strSQLCreateProc
Dim strSQLDropProc

'JetOLEDB4.0
adoConnectString="Provider=Microsoft.JET.OLEDB.4.0;" & _
    "Data Source=D:\inetPub\wwwRoot\Databases\Northwind.mdb;" & _
    "User ID=Admin;Password=;"

Set adoConnection = CreateObject("adodb.connection")
With adoConnection
  .CursorLocation = adUseClient
  .Open adoConnectString
End With
 
strSQLCreateProc = "Create Procedure uspInsertShipper(" & _
            "@parm1 VarChar(40)," & _
            "@parm2 VarChar(24))" & _
            "as " & _
            "INSERT INTO Shippers (CompanyName, Phone)" & _
            "VALUES(@parm1, @parm2)"

strSQLDropProc = "Drop Procedure uspInsertShipper"
 
On Error Resume Next
adoConnection.Execute (strSQLDropProc)
On Error GoTo 0
adoConnection.Execute (strSQLCreateProc)

'* Comment this code (And uncomment the AdoX code below) to fix the error.
Set adoCommand = CreateObject("adodb.command")
Set adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = "uspInsertShipper"
adoCommand.CommandType = adCmdStoredProc
adoCommand.Parameters.Append adoCommand.CreateParameter("parm1", adVarWChar, adParamInput, 40)
adoCommand.Parameters.Append adoCommand.CreateParameter("parm2", adVarWChar, adParamInput, 24)
adoCommand.Parameters.Refresh

'* Uncomment this code (And comment the AdoDb code above) to fix the error.
'Set adoCatalog = CreateObject("adox.catalog")
'Set adoCatalog.ActiveConnection = adoConnection
'Set adoCommand = adoCatalog.Procedures("uspInsertShipper").Command
'adoCommand.Parameters.Append adoCommand.CreateParameter("parm1", adVarWChar, adParamInput, 40)
'adoCommand.Parameters.Append adoCommand.CreateParameter("parm2", adVarWChar, adParamInput, 24)
'adoCommand.Parameters.Refresh

Response.Write "The parameter properties for uspInsertShipper: " & "<br>" _
& "Name: " & adoCommand.Parameters(0).Name & "<br>" _
& "Type: " & adoCommand.Parameters(0).Type & "<br>" _
& "Direction: " & adoCommand.Parameters(0).Direction & "<br>" _
& "Size: " & adoCommand.Parameters(0).Size

Set adoCommand = Nothing
Set adoConnection = Nothing
Set adoCatalog = Nothing
%>
</HTML>
</BODY>
                


Additional query words: error 0x800A0CC1

Keywords: kbprb KB253627