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

高手帮忙看看这段代码哪里有问题!
[javascript]我想接收网页传送来的askn和askp两个变量,然后打开users.mdb查找看是否有同时存在两个变量的一行,如果有,变量res=2,没有res=0.然后输出res的值
代码如下:
<%@LANGUAGE= "JAVASCRIPT "   CODEPAGE= "936 "%>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>
<body>
</body>
</html>
<%  
var   namenow=new   String();
var   passnow2=new   String();
var   str_askn=new   String();
var   str_askp=new   String();
res=0
passnow= " "
str_askn=Request.QueryString( "askn ");
str_askp=Request.QueryString( "askp ");
StrConnect   =   "Driver={Microsoft   Access   Driver   (*.mdb)};   DBQ=e:/inetpub/wwwroot/users.mdb ";
objConn   =   Server.CreateObject( "ADODB.Connection ");
objConn.open(StrConnect);
objRec   =   Server.CreateObject( "ADODB.Recordset ");
objRec.open( "list2 ",StrConnect,0,1,2)
while(!objRec.eof){
      namenow=objRec( "username ");
      passnow2=objRec( "password ");
      if(str_askn==namenow){
      res   +=1;
      };    
      if(str_askp==passnow2){
      res   +=1;
      };
        objRec.MoveNext;
}
Response.Write( "output= "+res);
%>
我试过输出str_askn和str_askp的值,完全正常,str_askn和namenow的值完全相等,str_askp和passnow2的值也完全相等,但是res始终等于零,也就是说if里的语句没有执行.请问是怎么回事呢?应该怎样修改?

------解决方案--------------------
objRec.open( "list2 ",StrConnect,0,1,2)

"list2 "是什么?
------解决方案--------------------
objRec.open( "list2 ",StrConnect,0,1,2)

错在这一行