![]() |
#2
Artless2012-12-14 12:54
|
Adodc.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\个人文件夹\表.mdb;Persist Security Info=False"
Adodc.RecordSource = "SELECT year([日期]) AS 年份, Month([日期]) AS 月份 FROM 表"
If Cbo年.Text <> "" Then
If Len(strWhere) = 0 Then
strWhere = "" 年份" like '%" & Cbo年.Text & "%'"
Else
strWhere = strWhere & "and " 年份 " like '%" & Cbo年.Text & "%'"
End If
End If
If Cbo月.Text <> "" Then
If Len(strWhere) = 0 Then
strWhere = "" 月份 " like '%" & Cbo月.Text & "%'"
Else
strWhere = strWhere & "and " 月份 " like '%" & Cbo月.Text & "%'"
End If
End If
Adodc包.RecordSource = "select * from 表 where " & strWhere
Adodc包.Refresh
通过组合框想要查询年和月,但是始终显示“至少一个参数没有被指定”。
应该怎么编写这个代码才对?
