日期:2014-05-19  浏览次数:20519 次

用户登陆问题
第一行:“=”附近有语法错误     我查不到哪里有错啊?帮帮忙!!

//检测用户输入的用户名和密码的正确性
private   void   submit_Click(object   sender,   System.EventArgs   e)
{
string   str;
if(txtlogname.Text== " "||txtlogpwd.Text== " ")
{
Response.Write( " <script> javascript:alert( '您输入的用户名或密码有一项为空,为了安全起见,请每项都输入! '); </script> ");
Response.Write( "javascript:window.location= 'Login.aspx ' ");
}
else
{
str= "select   count(*)   as   count   from   login   where   login_ID= ' "   +   txtlogname.Text+   " '   ";
conn.Open();
com=new   SqlCommand(str,conn);
dr   =   com.ExecuteReader();
string   icount= " ";
while(dr.Read())
{
icount=dr[ "count "].ToString();
}
                                dr.Close();
conn.Close();

string   usersid,user_roleid;
if(icount!= "0 ")
{
string   sql= "select   users_id,Role_ID   from   login   where   login_ID=login_ID= ' "   +   txtlogname.Text+   " '   and   password= ' "   +   txtlogpwd.Text   +   " ' ";
conn.Open();
com=new   SqlCommand(sql,conn);

dr   =   com.ExecuteReader();       //此处出错
while(dr.Read())
{
usersid=dr[0].ToString();
Session[ "users_id "]=usersid;
user_roleid=dr[1].ToString();
// Session[ "Role_ID "]=user_roleid;
if(user_roleid!= "0 ")
{
Response.Write( " <script> javascript:alert( '您是普通用户,只具有一般的浏览和查询的权限! '); </script> ");
Response.Redirect( "search_person.aspx ");
}
else
{
Response.Write( " <script> javascript:alert( '您是超级用户,具有管理员工信息的权限! '); </script> ");
Response.Redirect( "manage.aspx ");
}
}
dr.Close();
conn.Close();
}
else
{
message.Visible=true;
message.Text= "您不是公司的员工,无权访问! ";
}
}
}


------解决方案--------------------
string sql= "select users_id,Role_ID from login where login_ID=login_ID= ' " + txtlogname.Text+ " ' and password= ' " + txtlogpwd.Text + " ' ";
===============================================================================
string sql= "select users_id,Role_ID from login where login_ID= ' " + txtlogname.Text+ " ' and password= ' " + txtlogpwd.Text + " ' ";
------解决方案--------------------
还有 把你的
if(user_roleid!= "0 ")
{
Response.Write( " <script> javascript:alert( '您是普通用户,只具有一般的浏览和查询的权限! '); </script> ");
Response.Redirect( "search_person.aspx ");
}
else
{
Response.Write( " <script> javascript:alert( '您是超级用户,具有管理员工信息的权限! '); </script> ");
Response.Redirect( "manage.aspx ");
}

改成
if(user_roleid!= "0 ")
{
Response.Write( "