vb如何点击按钮后,datagrid表才会显示数据?而不是直接加载
2个回答
展开全部
Private Sub Command1_Click()
Dim db As New ADODB.Connection '定义数据库的连接
Dim strCnn As String
Dim rs As New ADODB.Recordset
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\wd.mdb" ';Persist Security Info=False"
db.Open strCnn
rs.CursorLocation = 3
rs.Open "select * from jishijilu", strCnn, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询