vb查询access数据库只显示一条记录 20
OptionExplicitDimconnAsADODB.ConnectionDimrsAsADODB.RecordsetDimcmdAsADODB.CommandPri...
Option Explicit
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
conn.ConnectionString = "provider=Microsoft.jet.OLEDB.4.0;" & "data source=" & App.Path & "\database.mdb;" & "persist security info=false"
conn.Open
cmd.CommandType = adCmdText
cmd.ActiveConnection = conn
If Combo1.Text = "" Then
MsgBox "条件不能为空值,请重新输入"
ElseIf Combo1.Text = "客户" Then
cmd.CommandText = "select*from test where 客户='" & Text16.Text & "'"
ElseIf Combo1.Text = "件数" Then
cmd.CommandText = "select*from test where 件数='" & Text16.Text & "'"
ElseIf Combo1.Text = "车牌号" Then
cmd.CommandText = "select*from test where 车牌号='" & Text16.Text & "'"
ElseIf Combo1.Text = "驾驶员" Then
cmd.CommandText = "select*from test where 驾驶员='" & Text16.Text & "'"
ElseIf Combo1.Text = "驾驶员电话" Then
cmd.CommandText = "select*from test where 驾驶员电话='" & Text16.Text & "'"
End If
Set rs = cmd.Execute
Set MSHFlexGrid1.DataSource = rs
rs.Close
conn.Close
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "provider=Microsoft.jet.OLEDB.4.0;" & "data source=" & App.Path & "\database.mdb;" & "persist security info=false"
conn.Open
rs.Open "test", conn, , adCmdTable
Set MSHFlexGrid1.DataSource = rs
rs.Close
conn.Close
Combo1.AddItem "客户"
Combo1.AddItem "电话"
Combo1.AddItem "件数"
Combo1.AddItem "车牌号"
Combo1.AddItem "驾驶员"
Combo1.AddItem "驾驶员电话"
End Sub 展开
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim cmd As ADODB.Command
Private Sub Command1_Click()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
conn.ConnectionString = "provider=Microsoft.jet.OLEDB.4.0;" & "data source=" & App.Path & "\database.mdb;" & "persist security info=false"
conn.Open
cmd.CommandType = adCmdText
cmd.ActiveConnection = conn
If Combo1.Text = "" Then
MsgBox "条件不能为空值,请重新输入"
ElseIf Combo1.Text = "客户" Then
cmd.CommandText = "select*from test where 客户='" & Text16.Text & "'"
ElseIf Combo1.Text = "件数" Then
cmd.CommandText = "select*from test where 件数='" & Text16.Text & "'"
ElseIf Combo1.Text = "车牌号" Then
cmd.CommandText = "select*from test where 车牌号='" & Text16.Text & "'"
ElseIf Combo1.Text = "驾驶员" Then
cmd.CommandText = "select*from test where 驾驶员='" & Text16.Text & "'"
ElseIf Combo1.Text = "驾驶员电话" Then
cmd.CommandText = "select*from test where 驾驶员电话='" & Text16.Text & "'"
End If
Set rs = cmd.Execute
Set MSHFlexGrid1.DataSource = rs
rs.Close
conn.Close
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "provider=Microsoft.jet.OLEDB.4.0;" & "data source=" & App.Path & "\database.mdb;" & "persist security info=false"
conn.Open
rs.Open "test", conn, , adCmdTable
Set MSHFlexGrid1.DataSource = rs
rs.Close
conn.Close
Combo1.AddItem "客户"
Combo1.AddItem "电话"
Combo1.AddItem "件数"
Combo1.AddItem "车牌号"
Combo1.AddItem "驾驶员"
Combo1.AddItem "驾驶员电话"
End Sub 展开
1个回答
百事牛
2024-10-28 广告
2024-10-28 广告
要取消Excel表格的密码,如果您知道密码,最直接的方式是在打开文件后,点击“文件”>“信息”,然后找到“保护工作簿”下的“用密码进行加密”。在弹出的对话框中,删除已设置的密码,点击“确定”并保存更改即可。若忘记密码,您可能需要考虑使用专业...
点击进入详情页
本回答由百事牛提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询