添加四个comol,一个Adodc,一个DataGrid控件
Private Sub Command1_Click()
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from ss where 国籍 like '" & Combo1.Text & "' and 性别 like '" & Combo2.Text & "'and 年龄段 like '" & Combo3.Text & "'and 百分比 like '" & Combo4.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "无数据"
Else
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
End If
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=aa.mdb"
End Sub
1,
'& text1.text & '
改成 '" & text1.text & "'
2,
recordset("[开始时间]")
改成 recordset!开始时间
Adodc1.RecordSource = "select * from 表名 where 字段名= '" & text1.Text & "'"
表名,是你打开数据库后里面的表名称
字段名,是你打开的表中的某个字段
这些都不需要再加[ ]这个括号
With Adodc1.Recordset
label3=!商品名称
end with
没有看见你设置
adodc对象的Adodc1.ConnectionString 属性