I've a DataGrid Control in my application and a button. When i click a button it should display the contents of the Logins table in the DataGrid. For this I've coded the following, but its giving me an error "Rowset is not bookmarkable.". I've searched a lot, many suggestions include changing Recordset cursor type and cursor location. But those suggestions don't solve my problem..


My Code ::

Private Sub OpenConnection()
    Set dbConnection = New ADODB.Connection
    dbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & "G:\ShopManProject\" & "dbShopMan.mdb"

    Set dbCommand = New ADODB.Command
    Set dbCommand.ActiveConnection = dbConnection
    dbCommand.CommandType = adCmdText
End Sub

Private Sub Command5_Click()
    dbCommand.CommandText = "select * from Logins"
    Set dbRecordset = New ADODB.Recordset
    dbRecordset.CursorLocation = adUseClient
    dbRecordset.CursorType = adOpenKeyset
    dbRecordset.LockType = adLockOptimistic
    Set dbRecordset = dbCommand.Execute
    Set dataGridItems.DataSource = dbRecordset
End Sub

I prefer to do it the following way because of a shared recordset...

Private Sub Command5_Click()
    Dim cnGrid As ADODB.Connection
    Set cnGrid = New ADODB.Connection 

    cnGrid.Open "provider = microsoft.jet.oledb.4.0;persist security info=false;data source = " & "G:\ShopManProject\" & "\dbShopMan.mdb"
    cnGrid.CursorLocation = adUseClient ''or adUseServer depending on your connection...

    Dim dbRecordset As New ADODB.Recordset
    Set dbRecordset = New ADODB.Recordset

    dbRecordset.Open "SELECT * FROM Logins" cnGrid, adOpenDynamic, adLockPessimistic

    Set dataGridItems.DataSource = dbRecordset
End Sub

Thank you.. Thanks a lot.. The difference was to to provide CursorLocation of ADODB Connection..

This question has already been answered. Start a new discussion instead.