Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I want to populate datagrid use a SQL Query. I don't want to use ADODC kind of control.

Please suggest.
I wrote the coding but it's not working.

Dim db As ADODB.Connection
Dim rs As ADODB.Recordset

Set db = New ADODB.Connection
Set rs = New ADODB.Recordset
Dim str As String
str = "Select * from table1"
db.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\db1.mdb"
db.Open
Set rs = db.Execute(str)

Set DataGrid1.DataSource = rs

Error is saying RowSet is not bookmarkable

Any other code segment will also helpful for me.

I just want to populate the datagrid using a SQL Query.


Please Help
Posted
Updated 11-Apr-17 2:07am
v2

1 solution

You can solve it by adding CursorLocation = adUseClient

VB
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
 
Share this answer
 
Comments
[no name] 9-Jun-11 0:48am    
thanks!
can you tell me, what the above line will do?
Wild-Programmer 9-Jun-11 4:26am    
Read the article for detail @ http://dev.mysql.com/tech-resources/articles/vb-cursors-and-locks.html
[no name] 9-Jun-11 12:07pm    
Thank you so much

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900