VB6.0如何在DATAGRID控件中显示数据库内容啊?
2个回答
2013-09-10
展开全部
这是我做的一个示例,希望对你有所帮助!!Private conn As ADODB.Connection
Private rsmc As ADODB.RecordsetPrivate Sub Command1_Click()End SubPrivate Sub Command2_Click()
On Error Resume Next
i = MsgBox("是否清空所有历史记录?", vbYesNo + vbInformation, "提示")
If i = vbYes Then
rsmc.MoveFirst
While Not rsmc.EOF
rsmc.Delete
rsmc.MoveNext
Wend
End If
End SubPrivate Sub Command3_Click()
Me.Hide
End SubPrivate Sub Form_Activate()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\xs.mdb"
conn.Open
Set rsmc = New ADODB.Recordset
rsmc.CursorLocation = adUseClient
rsmc.Open "xtZZ", conn, 2, 2
Set DataGrid1.DataSource = rsmc
DataGrid1.Refresh
End Sub
Private rsmc As ADODB.RecordsetPrivate Sub Command1_Click()End SubPrivate Sub Command2_Click()
On Error Resume Next
i = MsgBox("是否清空所有历史记录?", vbYesNo + vbInformation, "提示")
If i = vbYes Then
rsmc.MoveFirst
While Not rsmc.EOF
rsmc.Delete
rsmc.MoveNext
Wend
End If
End SubPrivate Sub Command3_Click()
Me.Hide
End SubPrivate Sub Form_Activate()
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\xs.mdb"
conn.Open
Set rsmc = New ADODB.Recordset
rsmc.CursorLocation = adUseClient
rsmc.Open "xtZZ", conn, 2, 2
Set DataGrid1.DataSource = rsmc
DataGrid1.Refresh
End Sub
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
2013-09-10
展开全部
先把DATAGRID控件与ADODC控件进行绑定,然后只要ADO控件能连上数据库打开数据库表就行。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询