语法错误 (操作符丢失) 在查询表达式 'xh='040001kch=1xq=1jsh=1' and kch= and xq= and jsh=' 中。

来源:百度知道 编辑:UC知道 时间:2024/09/28 13:53:44
请大家帮帮忙,谢谢
我的程序为:
<!--#include file="conn.asp"-->
<%
dim xh,kch,xq,jsh,sqlstr,xg
xh=request.QueryString("xh")
kch=request.QueryString("kch")
xq=request.QueryString("xq")
jsh=request.QueryString("jsh")
xg=request.QueryString("xg")
sqlstr="select * from cjb where xh='"&xh&"' and kch="&kch&" and xq="&xq&" and jsh="&jsh
'response.Write(sqlstr)
set rs_xg = server.CreateObject("adodb.recordset")
rs_xg.open sqlstr,conn,2,3
rs_xg.movefirst
if len(xg)=0 then
%>

很明显,好象你传过去的整数参数为空的话就出错了.
还有你的程序不进行防注入的?? 整型参数一般这样传

Function RtnReplaceInt(iCheck,iDefault)
If Trim(iCheck)="" Then
RtnReplaceInt = iDefault
Exit Function
End If

If IsNumeric(iCheck)=false Then
RtnReplaceInt = iDefault
Exit Function
End If

RtnReplaceInt = iCheck
End Function

这个是一个简单的整形验证函数:

xg=RtnReplaceInt(request.QueryString("xg")
,0)

这样如果整形参数为空的话就可以替换成0了.