ACCESS 中SQL语句问题
系统使用ADO与ACCESS连接,以下代码,在ACCESS的查询视图中无记录显示,没关系,在ADO连接时,可以显示记录SELECT linezc.linezcid, linezc.Proname,linezc.inputdate, linezc.barcodes,COUNT (linezcinfo.linezcinfiid) AS usednum, linezc.wzdm,wzbom.wzname, wzbom.wztype, linezc.facid, factory.factory,linezc.tjng,linezc.ngdemo, linezc.ngnum, linezc.checkdate, linezc.checkpro, linezc.zcstatus, linezc.zcdemo FROM ((linezc LEFT JOIN wzbom ON wzbom.wzdm = linezc.wzdm) LEFT JOIN factory ON factory.facid = linezc.facid) LEFT JOIN linezcinfo ON linezcinfo.barcodes = linezc.barcodes where (wztype like '%hs350%' ) GROUP BY linezc.linezcid,linezc.Proname,linezc.inputdate, linezc.barcodes,linezc.wzdm, wzbom.wzname, wzbom.wztype, linezc.facid, factory.factory, linezc.tjng,linezc.ngdemo, linezc.ngnum, linezc.checkdate, linezc.checkpro, linezc.zcstatus, linezc.zcdemo ORDER BY linezc.inputdate desc
但是如何,红色部分改成
SELECT linezc.linezcid, linezc.Proname,linezc.inputdate, linezc.barcodes,COUNT (linezcinfo.linezcinfiid) AS usednum, linezc.wzdm,wzbom.wzname, wzbom.wztype, linezc.facid, factory.factory,linezc.tjng,linezc.ngdemo, linezc.ngnum, linezc.checkdate, linezc.checkpro, linezc.zcstatus, linezc.zcdemo FROM ((linezc LEFT JOIN wzbom ON wzbom.wzdm = linezc.wzdm) LEFT JOIN factory ON factory.facid = linezc.facid) LEFT JOIN linezcinfo ON linezcinfo.barcodes = linezc.barcodes where (wzname like '%电源%' ) GROUP BY linezc.linezcid,linezc.Proname,linezc.inputdate, linezc.barcodes,linezc.wzdm, wzbom.wzname, wzbom.wztype, linezc.facid, factory.factory, linezc.tjng,linezc.ngdemo, linezc.ngnum, linezc.checkdate, linezc.checkpro, linezc.zcstatus, linezc.zcdemo ORDER BY linezc.inputdate desc
无记录显示
唯一的区分是中文和英文的区别
考虑到时否是编码的问题,在客户端用encodeURI(ds.lastOptions.params.query)编码;
服务器端query = URLDecode(request("query"))
函数如下(网上复制的):
function URLDecode(enStr)
dim deStr, strSpecial
dim c, i, v
deStr = ""
strSpecial = "!""#$%&'()*+,.-_/:;<=>?@[\]^`{|}~%"
for i = 1 to Len(enStr)
c = Mid(enStr, i, 1)
if c = "%" then
v = eval("&h" + Mid(enStr, i + 1, 2))
if inStr(strSpecial, chr(v)) > 0 then
deStr = deStr & chr(v)
i = i + 2
else
v = eval("&h" + Mid(enStr, i+1, 2) + Mid(enStr, i+4, 2))
deStr = deStr & chr(v)
i = i + 5
end if
else
if c = "+" then
deStr = deStr & " "
else
deStr = deStr & c
end if
end if
next
URLDecode = deStr
end Function
跟上面一样效果,查询值为中文,不能显示记录
Set rs88 = server.CreateObject("adodb.recordset")
rs88.Open sql1, conn, 1, 1
mycount = CInt(rs88.recordcount)
'response.write(mycount)
rs88.Close
Set rs88 = Nothing
response.write mycount
response.End
中文显示为0 ,英文有记录数