VB中DataGrid控件已经用ADO控件和数据库连接了,可是运行时无法显示数据表,下面是窗体加载代码,为什么呢 5
Adodc1.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&App.Path&"\DB_...
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tb_djys"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tb_djys"
Adodc2.Refresh 展开
Adodc1.RecordSource = "select * from tb_djys"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DB_KFGL.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tb_djys"
Adodc2.Refresh 展开
展开全部
需要连接的是记录集啊。。。。比如:
Dim CN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\NWIND.MDB;Persist Security Info=False "
CN.Open
Rs.CursorLocation = adUseClient
Rs.Open "select * from employees ", CN, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = Rs '这里,连接的是记录集。。。
Dim CN As New ADODB.Connection
Dim Rs As New ADODB.Recordset
CN.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\NWIND.MDB;Persist Security Info=False "
CN.Open
Rs.CursorLocation = adUseClient
Rs.Open "select * from employees ", CN, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = Rs '这里,连接的是记录集。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询