使用代码在VB 6.0中填充Datagrid [英] Populate Datagrid in VB 6.0 using code
本文介绍了使用代码在VB 6.0中填充Datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我想填充datagrid使用SQL查询。我不想使用ADODC那种控制。
请建议。
我编写了编码,但它没有用。
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
错误说RowSet不可收藏
任何其他代码段对我也有帮助。
我只想使用SQL查询填充数据网格。
请帮助
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
推荐答案
您可以通过添加CursorLocation = adUseClient来解决它
You can solve it by adding CursorLocation = adUseClient
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
这篇关于使用代码在VB 6.0中填充Datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文