Microsoft Knowledge Base Email Alertz

Using ActiveX Data Objects (ADO) and the Microsoft OLEDB Provider or ODBC Driver for SQL Server, to retrieve a recordset from a stored procedure using Server-side Cursors, returns a Forward-only/Read-only recordset if that stored procedure

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 246636 - Last Review: May 8, 2003 - Revision: 2.1

PRB: Multiple Statements in Stored Procedure Causes Forward-Only/Read-Only Recordsets

This article was previously published under Q246636

On This Page

SYMPTOMS

Using ActiveX Data Objects (ADO) and the Microsoft OLEDB Provider or ODBC Driver for SQL Server, to retrieve a recordset from a stored procedure using Server-side Cursors, returns a Forward-only/Read-only recordset if that stored procedure contains anything other than a single SELECT statement. When the recordset is edited, the following run-time error occurs:
3251 "Provider Does Not Support This Operation"

CAUSE

SQL Server cannot provide schema information necessary for updates if the stored procedure contains more than just a SELECT statement.

RESOLUTION

You can use client-side cursors in order to get a read-only Static cursor, which allows scrolling and bookmarks. You will have to manage updates yourself.

MORE INFORMATION

Steps to Reproduce Behavior

Use these steps to reproduce the problem:
  1. Create the following Stored Procedure in SQL Server 7.0 under the Pubs database.
    CREATE procedure Test
    @f int
    as
    if @f = 2
    begin
    Select  *  from authors
    End
    					
  2. Start a new Visual Basic Standard EXE project. Form1 is added by default.
  3. From the Project menu, click References, and then select Microsoft ActiveX Data Objects.
  4. Place the following code in Form1:
    Private Sub Form_Load()
    Dim strSQL As String
    Dim cn as ADODB.Connection
    Dim rst As ADODB.Recordset
    
    Set cn = New ADODB.Connection
    Set rst = New ADODB.Recordset
    
    cn.ConnectionString = "Provider=SQLOLEDB;Data Source=Server;User ID=UserName;Password=Password;Initial Catalog=pubs"
    cn.Open
    
    strSQL = "exec Test 2"
    rst.Open strSQL, cn, adOpenKeyset, adLockBatchOptimistic, adCmdText
    
    rst("au_lname") = "xxxxx" 'Error Occurs Here
    rst.UpdateBatch
    rst.MoveNext
    End Sub
    					
  5. Run the Project.
RESULT: This error occurs:
Run-time Error '3251': Provider Does Not Support This Operation.

APPLIES TO
  • Microsoft ActiveX Data Objects 2.1
  • Microsoft ActiveX Data Objects 2.1 Service Pack 2
  • Microsoft ActiveX Data Objects 2.5
  • Microsoft ActiveX Data Objects 2.6
  • Microsoft ActiveX Data Objects 2.7
  • Microsoft OLE DB Provider for SQL Server 7.0
  • Microsoft OLE DB Provider for SQL Server 7.01
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
Keywords: 
kbprb kbstoredproc KB246636
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate