Microsoft KB Archive/253627: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "<" to "<")
Line 80: Line 80:
<br />
<br />
'''NOTE''': The code as provided here demonstrates the error. Refer to the comments in the code to avoid the error.
'''NOTE''': The code as provided here demonstrates the error. Refer to the comments in the code to avoid the error.
<pre class="codesample">&lt;HTML&gt;
<pre class="codesample"><HTML&gt;
&lt;BODY&gt;
<BODY&gt;
&lt;%@ Language=VBScript %&gt;
<%@ Language=VBScript %&gt;
&lt;!-- #INCLUDE VIRTUAL=&quot;/ADOVBS.INC&quot; --&gt;
<!-- #INCLUDE VIRTUAL=&quot;/ADOVBS.INC&quot; --&gt;
&lt;%
<%
Dim adoConnection
Dim adoConnection
Dim adoCommand
Dim adoCommand
Line 133: Line 133:
'adoCommand.Parameters.Refresh
'adoCommand.Parameters.Refresh


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


Line 143: Line 143:
Set adoCatalog = Nothing
Set adoCatalog = Nothing
%&gt;
%&gt;
&lt;/HTML&gt;
</HTML&gt;
&lt;/BODY&gt;
</BODY&gt;
                 </pre>
                 </pre>



Revision as of 09:01, 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