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

江湖救急啊~今天要交!!麻烦各位帮下小忙,真是急死了。。
第2个if语句中老是不执行,就跳到ELSE中,如果不要第二个if语句旧能进聊天室,可是这样竟不去管理页面,要的话,点进入聊天室按钮一直就像在刷屏,悲催的一直在登陆页面~真是2012.6.18要交啊。。帮帮学生妹子吧!!大侠们~[color=#FF0000][/color]
using System;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{

  protected void Page_Load(object sender, EventArgs e)
  {
  this.Title = "请登录";
  UserName.Focus();
  }
   
  protected void UserLogin_Click(object sender, EventArgs e)
  {
  if (UserName.Text == "" || Password.Text == "")
  {
  Response.Write("<script language=javascript>alert('请输入完整的登录信息!');</script>");
  return;
  }
   
  using (OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["db1ConnectionString"].ToString()))
  try
  {
  con.Open();
  string sql = "select * from tbUser where Username='" + UserName.Text + "'and Password='" + Password.Text + "'";
  OleDbCommand cmd = new OleDbCommand(sql, con);
  using (OleDbDataReader re = cmd.ExecuteReader())
  {
  string name = string.Empty;
  string pwd = string.Empty;
  string nick = string.Empty;
  Int32 power = 0;
  while (re.Read())
  {
  Session["name"] = re["Username"].ToString();
  Session["nick"] = re["Nick"].ToString();
  Session["pwd"] = re["Password"].ToString();
  Session["power "] = Int32.Parse(re["Power"].ToString());
  }

  if (name.Trim() == UserName.Text.Trim() && pwd.Trim() == Password.Text.Trim())
{
if (power == 1) //power == 1,管理员登陆;为0为普通用户登陆
{
Response.Redirect("../聊天室/admin/main.aspx");
}

else
{
Response.Redirect("../聊天室/chat.htm");
}
} }
  }
  catch (Exception ex)
  {
  throw;
  }
  }
  protected void NewUser_Click(object sender, EventArgs e)
  {
  Response.Redirect("../聊天室/zhuce.aspx");
  }
   
}

------解决方案--------------------
大侠都很忙的,只有我这种小菜才有时间的。。。
这样改下
C# code

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.We