Microsoft KB Archive/253627: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "&" to "&")
m (Text replacement - """ to """)
 
Line 83: Line 83:
<BODY>
<BODY>
<%@ Language=VBScript %>
<%@ Language=VBScript %>
<!-- #INCLUDE VIRTUAL=&quot;/ADOVBS.INC&quot; -->
<!-- #INCLUDE VIRTUAL="/ADOVBS.INC" -->
<%
<%
Dim adoConnection
Dim adoConnection
Line 92: Line 92:


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


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


strSQLDropProc = &quot;Drop Procedure uspInsertShipper&quot;
strSQLDropProc = "Drop Procedure uspInsertShipper"
   
   
On Error Resume Next
On Error Resume Next
Line 117: Line 117:


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


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


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


Set adoCommand = Nothing
Set adoCommand = Nothing

Latest revision as of 13:52, 21 July 2020

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