Microsoft KB Archive/248144: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "&" to "&")
m (Text replacement - """ to """)
 
Line 12: Line 12:
<div id="TitleRow">
<div id="TitleRow">


= <span id="KB248144"></span>PRB: Error: &quot;Not capable&quot; When Opening a Record Object Off a Recordset =
= <span id="KB248144"></span>PRB: Error: "Not capable" When Opening a Record Object Off a Recordset =




Line 86: Line 86:
Command1 and Command2 are created by default.</li>
Command1 and Command2 are created by default.</li>
<li>From the '''Project''' menu, select References. In the '''References''' dialog box select the Microsoft ActiveX Data Objects Library.</li>
<li>From the '''Project''' menu, select References. In the '''References''' dialog box select the Microsoft ActiveX Data Objects Library.</li>
<li><p>Paste the following code into the &quot;General Declarations&quot; section of Form1's Code Window:</p>
<li><p>Paste the following code into the "General Declarations" section of Form1's Code Window:</p>
<pre class="codesample">  Private Sub Command1_Click()
<pre class="codesample">  Private Sub Command1_Click()
      
      
Line 95: Line 95:
       Set rec = New ADODB.Record
       Set rec = New ADODB.Record
      
      
       rs.Open &quot;&quot;, &quot;URL=http://localhost/&quot;, , , adCmdTableDirect
       rs.Open "", "URL=http://localhost/", , , adCmdTableDirect
       rec.Open rs
       rec.Open rs
      
      
Line 115: Line 115:
       Set rec = New ADODB.Record
       Set rec = New ADODB.Record


       rs.Open &quot;Employees&quot;, &quot;Provider=sqloledb;&quot; & _
       rs.Open "Employees", "Provider=sqloledb;" & _
               &quot;Data Source=server;user id=sa;password=password;&quot; & _
               "Data Source=server;user id=sa;password=password;" & _
               &quot;initial catalog=northwind;&quot;, _
               "initial catalog=northwind;", _
                 adOpenStatic, adLockReadOnly, adCmdTableDirect
                 adOpenStatic, adLockReadOnly, adCmdTableDirect
      
      

Latest revision as of 12:51, 21 July 2020

Article ID: 248144

Article Last Modified on 9/24/2003



APPLIES TO

  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6
  • Microsoft Data Access Components 2.7
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7



This article was previously published under Q248144

SYMPTOMS

When you attempt to open an ADO Record object using an ADO recordset, the following error appears:

Run-time error '3251':
Object or provider is not capable of performing requested operation.

CAUSE

The underlying OLE DB provider does not support the ADO record object.

STATUS

This behavior is by design.

MORE INFORMATION

The ADO documentation states that an ADO record can represent a row in a Recordset. However, the underlying OLE DB provider must support the ADO Record object. For example, the Microsoft OLE DB Provider for Internet Publishing supports the ADO Record object.

Steps to Reproduce Behavior

This sample uses the NWind.mdb database that comes with Visual Basic.

  1. In Visual Basic, create a new Standard EXE project.
    Form1 is created by default.
  2. Add a two Command buttons to Form1.
    Command1 and Command2 are created by default.
  3. From the Project menu, select References. In the References dialog box select the Microsoft ActiveX Data Objects Library.
  4. Paste the following code into the "General Declarations" section of Form1's Code Window:

       Private Sub Command1_Click()
        
           Dim rs As ADODB.Recordset
           Dim rec As ADODB.Record
        
           Set rs = New ADODB.Recordset
           Set rec = New ADODB.Record
        
           rs.Open "", "URL=http://localhost/", , , adCmdTableDirect
           rec.Open rs
        
           MsgBox rec(0).Value
        
           rec.Close
           Set rec = Nothing
           rs.Close
           Set rs = Nothing
        
       End Sub    
        
       Private Sub Command2_Click()
       
           Dim rs As ADODB.Recordset
           Dim rec As ADODB.Record
        
           Set rs = New ADODB.Recordset
           Set rec = New ADODB.Record
    
           rs.Open "Employees", "Provider=sqloledb;" & _
                   "Data Source=server;user id=sa;password=password;" & _
                   "initial catalog=northwind;", _
                    adOpenStatic, adLockReadOnly, adCmdTableDirect
        
           'The error occurs on the following line:
           rec.Open rs
        
           rec.Close
           Set rec = Nothing
           rs.Close
           Set rs = Nothing
        
       End Sub
  5. Modify the Connection strings to point to your server and database.
  6. Click F5 to start your Visual Basic program.
    Click Command1. No error occurs when using the Internet Publishing Provider.
    Click Command2. Note the error when using the Microsoft Jet OLE DB provider.


REFERENCES

You may find complete documentation on the Microsoft ActiveX Data Objects at
Microsoft ActiveX Data Objects

Keywords: kbprovider kbdatabase kbprb KB248144