为什么vbSQL查询出现错误P
Set cn = New ADODB。Connection
Set rs = New ADODB。Recordset
cn。CursorLocation = adUseClient
cn。 ConnectionString = "DBQ=" & App。Path & "\data\db1。mdb;DefaultDir=" & _
App。 Path & "\data;Driver={Microsoft Access Driver (*。mdb)};" & _
"DriverId=25;F...全部
Set cn = New ADODB。Connection
Set rs = New ADODB。Recordset
cn。CursorLocation = adUseClient
cn。
ConnectionString = "DBQ=" & App。Path & "\data\db1。mdb;DefaultDir=" & _
App。
Path & "\data;Driver={Microsoft Access Driver (*。mdb)};" & _
"DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;" & _
"MaxBufferSize=4096;MaxScanRows=18;PageTimeout=15;SafeTransactions=0;" & _
"Threads=3;UID=ADMIN;UserCommitSync=Yes;PWD=admind1234;" '此处是设置密码的地方
cn。
open
'cn。open "PROVIDER=Microsoft。Jet。OLEDB。4。0;Data Source=" & App。Path & "\data\db1。
mdb;"
'cn。Open "PROVIDER=Microsoft。Jet。OLEDB。4。0;Data Source=app。
path +'\data\db1。mdb';" 'Initial Catalog=pubs;User Id=;Password="
'''''''''''''
If Check4。
Value = Checked Then
rs。open "select * from 财会目录 where 名称 = '" & searchDirPlace & "' and leaf_ID=0", cn, adOpenDynamic, adLockOptimistic
If Not rs。
EOF Then
aaa = rs。Fields("ID")
rs。Close
Else
rs。Close
MsgBox "没有符合条件的文章!", vbOKOnly + vbInformation, "抱歉!"
Exit Sub
End If
End If
'''''''''''
strFilter = Trim(IIf(strsearch = "", "'=ALL'", "内容备注 like " & "'%" & strsearch & "%'")) & " and " & Trim(IIf(searchName = "", "'=ALL'", "名称 like " & "'%" & searchName & "%'")) & " and " & Trim(IIf(searchFileClass = "", "'=ALL'", "file_type like " & "'%" & searchFileClass & "%'")) & " and " & Trim(IIf(searchManger = "", "'=ALL'", "发文机关 like " & "'%" & searchManger & "%'")) & " and " & Trim(IIf(searchfileNo = "", "'=ALL'", "文件号 like " & "'%" & searchfileNo & "%'")) & " and " & Trim("file_date between #" & DTPicker1。
Value & "# and #" & DTPicker2。Value & "#") & " and " & Trim(IIf(searchDirPlace = "", "'=ALL'", "枝叶 = " & "" & aaa & ""))
'Trim(IIf(Text1。
Text = "", "'=ALL'", "姓名 like " & "'%" & Text1。Text & "%'"))
'strFilter = " " & stroption & " like " & " '% " & strsearch & " %' "
strgoods = "*" '"内容"
'c。
CommandText = "select * from 其他 where " & Trim(IIf(Text1。Text = "", "'=ALL'", "姓名 like " & "'%" & Text1。
Text & "%'")) & "and " & Trim(IIf(combo1。Text = "", "'=ALL'", "学号='" & Trim(combo1。
List(combo1。ListIndex)) & "'")) & "and " & Trim(IIf(text4。Text = "", "'=ALL'", "性别='" & Trim(text4。
List(text4。ListIndex)) & "'")) & " and " & Trim(IIf(Combo3。Text = "", "'=ALL'", "计算机水平='" & Trim(Combo3。
List(Combo3。ListIndex)) & "'")) & " and " & Trim(IIf(Combo4。Text = "", "'=ALL'", "英语水平='" & Trim(Combo4。
List(Combo4。ListIndex)) & "'")) & " and " & Trim(IIf(Combo5。Text = "", "'=ALL'", "就业意愿='" & Trim(Combo5。
List(Combo5。ListIndex)) & "'")) & " and " & Trim(IIf(Combo6。Text = "", "'=ALL'", "就业方向='" & Trim(Combo6。
List(Combo6。ListIndex)) & "'")) & " and " & Trim(IIf(Combo7。Text = "", "'=ALL'", "是否签约='" & Trim(Combo7。
List(Combo7。ListIndex)) & "'")) & " and " & Trim(IIf(Combo8。Text = "", "'=ALL'", "学生干部='" & Trim(Combo8。
List(Combo8。ListIndex)) & "'")) & "" 'and 前后必须要有空格,否则就出错
If strsearch = "" And Check1。
Value = Unchecked And Check2。Value = Unchecked And Check3。Value = Unchecked And Check4。
Value = Unchecked And Check5。Value = Unchecked And Check6。Value = Unchecked Then
MsgBox "请输入查询内容!", vbOKOnly, "缺少搜索内容"
Exit Sub
End If
strSQL = "Select " & strgoods & " From " & strtable & " Where " & strFilter & ";"
'strSQL = "Select * From 财会目录 Where 内容备注 like '%" & strsearch & "%' and 名称 like '%" & searchName & "%';"
rs。
open strSQL, cn, adOpenDynamic, adLockOptimistic
'rs。Open "select * from 财会目录 where file_date between '" & Format(DTPicker1。
Value, "yyyy-mm-dd") & "' and '" & Format(DTPicker2。Value, "yyyy-mm-dd") & "'", cn, 3, 1
'rs。
Open "select * from 财会目录 where file_date between '" & Format(DTPicker1。Value) & "' and '" & Format(DTPicker2。
Value) & "'", cn, adOpenKeyset, adLockOptimistic
。收起