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..

thanks..!!

My Code ::

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

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

Private Sub Command5_Click()
    OpenConnection
    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..

Only a pleasure. Happy coding. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.