sql语句提示 之前有未闭合的引号
sql="select * from jqls_cw where sj="'"+trim(ls_sj)+"'"
rs.open sql,cnn,adopenstatic,adlockoptimistic
变量ls_sj是从串口获取的数据
ls_sj值为 '{ee221105250947000006001200004340001000012000000022066 ' 中间的空格实际上不是空格而是乱码
也就是sql值为select count(*) from jqls_cw where sj='{ee221105250947000006001200004340001000012000000022066 '
如果ls_sj字符串内没有类似空格的乱码,不会出错,如果有类似空格的乱码,那么数据出错,并提示
错误提示:字符串 '{ee221105250947000006001200004340001000012000000022066' 之前有未闭合的引号。
[解决办法]
sql = "select * from jqls_cw where sj='" + trim(ls_sj) + "'"
[解决办法]
获得它的ascii码,把它剔除掉
[解决办法]
sql = "select * from jqls_cw where sj='" + trim(ls_sj) + "'"
[解决办法]
'将tab符替换成""sql=" select * from jqls_cw where sj ='"& trim(replace(ls_sj,vbTab,"")) &"'"将行结束符替换成""sql=" select * from jqls_cw where sj ='"& trim(replace(ls_sj,chr(0),"")) &"'"'将回车符换成""sql=" select * from jqls_cw where sj ='"& trim(replace(ls_sj,vbCrLf,"")) &"'"