2 回答
TA贡献1871条经验 获得超8个赞
ADODC+DATAGRID+ACCESS
大体如下,细节自己改:
Private Sub Form_Load()
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb;Persist Security Info=False"
.CommandType = adCmdText
.RecordSource = "select * from 表A"
.Refresh
Set DataGrid1.DataSource = Adodc1
For i = 1 To .Recordset.RecordCount
sbwenduup(i) = .Recordset.Fields(0)
sbwendulow(i) = .Recordset.Fields(1)
sbtime2(i) = .Recordset.Fields(2)
sbtime3(i) = .Recordset.Fields(3)
sbdianliuup(i) = .Recordset.Fields(4)
sbdianliuups(i) = .Recordset.Fields(5)
sbalarm(i) = .Recordset.Fields(6)
.Recordset.MoveNext
Next
End With
End Sub
TA贡献1966条经验 获得超4个赞
Private Sub Form_Load()
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db1.mdb;Persist Security Info=False" ‘连接数据库,C:\db1.mdb是数据库路径
.CommandType = adCmdText
.RecordSource = "select * from 表A" ‘对db1.mdb数据库执行的SQL语句
.Refresh
Set DataGrid1.DataSource = Adodc1
For i = 1 To .Recordset.RecordCount ’循环,i 从 1 到 上面的查询语句查出的数据条数
sbwenduup(i) = .Recordset.Fields(0) ‘Recordset.Fields(0) 表A第一列的数据
sbwendulow(i) = .Recordset.Fields(1) ’同理
sbtime2(i) = .Recordset.Fields(2)
sbtime3(i) = .Recordset.Fields(3)
sbdianliuup(i) = .Recordset.Fields(4)
sbdianliuups(i) = .Recordset.Fields(5)
sbalarm(i) = .Recordset.Fields(6)
.Recordset.MoveNext ‘移到下一组数据
Next
End With
End Sub
- 2 回答
- 0 关注
- 127 浏览
添加回答
举报