Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding a DataGrid with code

Status
Not open for further replies.

tcapp

Programmer
Apr 18, 2000
9
US
I have been trying to connect to a datagrid using the following code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim results As String
'Open Connection
Set cn = New ADODB.Connection
cn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\vendor1.mdb"
cn.Open
'Open Recordset
Set rs = New ADODB.Recordset
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
sSQL = "Select * from Vendor"
If g_sec <> &quot;&quot; Then sSQL = sSQL & &quot; Where SectionID ='&quot; & g_sec & &quot;'&quot;
rs.Source = sSQL
rs.ActiveConnection = cn
rs.Open

Set DataGrid1.DataSource = rs
DataGrid1.Refresh

All of the code is pretty generic, running out of a new form. At runtime I get &quot;Run-time error '7004' the rowset is not bookmarkable&quot; ???? Any Ideas
 
Hi,

I think the following answer may help u.
The cursortype in the code is adopendynamic.
The cursortypes adopendynamic ,adopenforwardonly won't
support bookmarkable property.

Change the cusortype property to either adopenkeyset
or adopenstatic.

ie rs.cursortype=adopenkeyset

Ur code will work.
Thank You
 
can't be done... the same error still shows up
 
Salut!

I tried your code.

You can't update the query and receive error message &quot;Insufficient base table information for updating or refreshing&quot; if you set:
cn.CursorLocation = adUseClient

You have error &quot;This recordset isn't bookmarkable&quot; if you set:
rs.CursorType = adOpenDynamic

It's all ok if you try exactly this:

cn.CursorLocation = adUseServer
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic

Bye!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top