if sbutton="1" then sqlt=" entry_id='"&dh&"'" end if改成: if sbutton="1" then sqlt=" and entry_id='"&dh&"'" end if
这个没有问题,放到查询分析器冲测试过。而且连起来是“select * from ok_tab where entry_id=***”,不需要加and.问题是第二个,sbutton=2 的时候 sql=sql+sqlt出来的语句,通不过。急呀~!
在sql="select * from ok_tab where"的where后加个空格 sql=sql&sqlt改成sql=sql&" "&sqlt
sql="select * from ok_tab where 关键字段 not null" if sbutton="1" then sqlt=" entry_id='"&dh&"'" end if if sbutton="2" then sqlt=" ship_id ='"&chuan if hangci<>"" then sqlt= sqlt&" and voyage_no ='"&hang&"'" end if end if session("sqlt")=sqlt sql=sql&sqlt response.Write(sql)
把sbutton=2时的SQL写出来的是什么???
这儿改成这样 if sbutton="2" then sqlt=" ship_id ='"&chuan&"'"
sql="select * from ok_tab where" if sbutton="1" then sqlt=" entry_id='"&dh&"'" elseif sbutton="2" then sqlt=" ship_id ='"&chuan if hangci<>"" then sqlt= sqlt&" and voyage_no ='"&hang&"'" end if end ifsession("sqlt")=sqlt sql=sql&sqlt if Length(rtrim(sql))=26 then'如果sqlt=null,就将where去掉 sql=left(sql,20) end if response.Write(sql)
sql="select * from ok_tab where" if sbutton="1" then sqlt=" entry_id=rtrim('"&dh&"')" end if if sbutton="2" then sqlt=" ship_id ='"&chuan if hangci<>"" then sqlt= sqlt&" and voyage_no =rtrim('"&hang&"')" end if end ifsession("sqlt")=sqlt sql=sql&sqlt response.Write(sql)
sql="select * from ok_tab where" if sbutton="1" then sqlt=" entry_id=rtrim('"&dh&"')" end if if sbutton="2" then sqlt=" ship_id =rtrim('"&chuan&"')" if hangci<>"" then sqlt= sqlt&" and voyage_no =rtrim('"&hang&"')" end if end ifsession("sqlt")=sqlt sql=sql&sqlt response.Write(sql)
sqlt=" entry_id='"&dh&"'"
end if改成:
if sbutton="1" then
sqlt=" and entry_id='"&dh&"'"
end if
sql=sql&sqlt改成sql=sql&" "&sqlt
if sbutton="1" then
sqlt=" entry_id='"&dh&"'"
end if
if sbutton="2" then
sqlt=" ship_id ='"&chuan
if hangci<>"" then
sqlt= sqlt&" and voyage_no ='"&hang&"'"
end if
end if
session("sqlt")=sqlt
sql=sql&sqlt
response.Write(sql)
if sbutton="2" then
sqlt=" ship_id ='"&chuan&"'"
sqlt=" entry_id='"&dh&"'"
elseif sbutton="2" then
sqlt=" ship_id ='"&chuan
if hangci<>"" then
sqlt= sqlt&" and voyage_no ='"&hang&"'"
end if
end ifsession("sqlt")=sqlt
sql=sql&sqlt
if Length(rtrim(sql))=26 then'如果sqlt=null,就将where去掉
sql=left(sql,20)
end if
response.Write(sql)
sqlt=" entry_id=rtrim('"&dh&"')"
end if
if sbutton="2" then
sqlt=" ship_id ='"&chuan
if hangci<>"" then
sqlt= sqlt&" and voyage_no =rtrim('"&hang&"')"
end if
end ifsession("sqlt")=sqlt
sql=sql&sqlt
response.Write(sql)
sqlt=" entry_id=rtrim('"&dh&"')"
end if
if sbutton="2" then
sqlt=" ship_id =rtrim('"&chuan&"')"
if hangci<>"" then
sqlt= sqlt&" and voyage_no =rtrim('"&hang&"')"
end if
end ifsession("sqlt")=sqlt
sql=sql&sqlt
response.Write(sql)