Microsoft KB Archive/278408

= PRB: Cannot Bind OLEDB DataGrid Control to Recordset That Does Not Support Bookmarks =

Article ID: 278408

Article Last Modified on 1/11/2001

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft ActiveX Data Objects 2.0
 * 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 Q278408



SYMPTOMS
When you attempt to bind an OLEDB DataGrid control to a forward-only or dynamic ActiveX Data Objects (ADO) recordset, you may receive the following run-time error message:

Run-time error '7004': The Rowset is not bookmarkable



CAUSE
You cannot bind the DataGrid control to recordsets that do not support bookmarks. The forward-only and dynamic ADO recordsets do not support bookmarks, and therefore cannot be specified as the DataSource for an OLEDB DataGrid control.



RESOLUTION
Bind the DataGrid to a bookmarkable recordset such as the keyset and static ADO recordsets.



Steps to Reproduce Behavior
 In Visual Basic version 6.0, create a new Data project. In the frmDataEnv form, add a DataGrid and a CommandButton control.  In the frmDataEnv form module, paste the following code:NOTE: Supply the required connection parameters to the cn.Open statement to connect to the SQL Server, and specify a valid table name in the rs.Open statement. 'General Declarations Section Dim cn As ADODB.Connection Dim rs As ADODB.Recordset

Private Sub Command1_Click

Set cn = New ADODB.Connection Set rs = New ADODB.Recordset

cn.Open &quot;Provider=SQLOLEDB;Data Source=<SQL Server>;Initial Catalog=<SQL Database>;User Id=<SQL UserId</I>>;Password=<SQL Password</I>>&quot; rs.Open &quot;Select * from <TableName</I>>&quot;, cn, adOpenDynamic, adLockOptimistic

Set DataGrid1.DataSource = rs

End Sub </li> Save and then run the project.</li> When frmDataEnv is displayed, click the command button. You receive the error specified in the &quot;Symptoms&quot; section of this article.

</li> Modify the rs.Open statement in the Command1_Click event procedure to open a keyset or a static ADO recordset. To do this, replace the constant adOpenDynamic with adOpenKeyset or adOpenStatic.</li> Save and then run the project.</li> On frmDataEnv, click the command button. The records in the specified table in the OLEDB DataGrid control are displayed.</li></ol>

Additional query words: 7004

Keywords: kbprb KB278408

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.