日期:2014-05-17  浏览次数:21023 次

asp中的select语句问题,我写的,但不知道错在哪里

dim   ObjConn,ObjRS,SqlStr,ConnStr
nian=   trim(request( "nian "))
tihao=   trim(request( "tihao "))

ConnStr=   "provider=microsoft.jet.oledb.4.0;   data   source=   "   &   _
server.mappath( "../../db/tiku.mdb ")

set   ObjConn=   server.createObject( "adodb.connection ")
set   ObjRS=   server.createObject( "adodb.recordset ")
ObjConn.open   Connstr

  SqlStr1=   "select   *   from   xuanxing     where   nian=   "   nian   &   "   and   "   &   _  
"tihao   =   "   &   tihao   & '; '
ObjRS.open   Sqlstr1,ObjConn,1,3


ObjRS.close

                set   ObjRS=   nothing
ObjConn.close
set   ObjConn=   nothing

------解决方案--------------------
similar answer showed

HTTP://www.ebigear.com/Fund/PlayNews.php?NewsID=28532&ID=285885
------解决方案--------------------
如果写select语句写的少的话,where条件就不要一下子写这么多,一个一个加,就容易找错了,楼上的已经给你指出了,少了一个&了.
------解决方案--------------------
SqlStr1= "select * from xuanxing where nian= "& nian & " 如果变量是字符则 ' "& nian & " '
and tihao = " & tihao 如果变量是字符则 ' "& nian & " ' "