Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

returning records in Access2000 & VB6

SandySandy Member Posts: 9
Hi everyone,
I am trying to connect to a database(VB6 and Access 2000 and ADO) and return the results of a recordset to a data grid. My message box tells me that the connection has been established but I get an error stating that "The rowset is not bookmarkable". I am not sure what to do about it. Can anyone see an issue with my code below?

Thanks,
Sandy


Private Sub Command2_Click()

Dim Cnxn2 As ADODB.Connection
Dim NewRs As ADODB.Recordset

' Open a connection using a DSN and ODBC tags
Set Cnxn2 = New ADODB.Connection

Cnxn2.ConnectionString = "Data Source='Passwords';" & _
"User ID='sa';Password='';"
Cnxn2.ConnectionTimeout = 30
Cnxn2.Open

If Cnxn2.State = adStateOpen Then
MsgBox "Cnxn2 state: YES "
Else
MsgBox "xxxxx"
End If

Set NewRs = Cnxn2.Execute("Select * from Users")

Set DataGrid1.DataSource = NewRs

NewRs.Close
Set NewRs = Nothing
Cnxn2.Close
Set Cnxn2 = Nothing

End Sub

Comments

  • jlegjleg Member Posts: 237
    : Hi everyone,
    : I am trying to connect to a database(VB6 and Access 2000 and ADO) and return the results of a recordset to a data grid. My message box tells me that the connection has been established but I get an error stating that "The rowset is not bookmarkable". I am not sure what to do about it. Can anyone see an issue with my code below?
    :
    : Thanks,
    : Sandy
    :
    :
    : Private Sub Command2_Click()
    :
    : Dim Cnxn2 As ADODB.Connection
    : Dim NewRs As ADODB.Recordset
    :
    : ' Open a connection using a DSN and ODBC tags
    : Set Cnxn2 = New ADODB.Connection
    :
    : Cnxn2.ConnectionString = "Data Source='Passwords';" & _
    : "User ID='sa';Password='';"
    : Cnxn2.ConnectionTimeout = 30
    : Cnxn2.Open
    :
    : If Cnxn2.State = adStateOpen Then
    : MsgBox "Cnxn2 state: YES "
    : Else
    : MsgBox "xxxxx"
    : End If
    :
    : Set NewRs = Cnxn2.Execute("Select * from Users")
    :
    : Set DataGrid1.DataSource = NewRs
    :
    : NewRs.Close
    : Set NewRs = Nothing
    : Cnxn2.Close
    : Set Cnxn2 = Nothing
    :
    : End Sub
    :
    DataGrids support bookmarks which means your recordset must provide for bookmarks. Your cursor and locktypes will determine whether or not the returned recordset will support bookmarks. Forward Only and dynamic recordsets do not support bookmarks. Try adding the following instead of

    adOpenKeySet, adLockOptimistic

    when opening your record set.

    John ;-)



Sign In or Register to comment.