当然 前面的查询什么 都没贴 和你的差不多
现在改了下 补全:
[C#] 纯文本查看 复制代码
Connection = new SqlConnection(strCon);
try
{
Connection.Open();
}
catch
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('錯誤!连接数据库失败,請檢查網絡是否正常');</script>");
return;
}
command = new SqlCommand("Select * From Users where EmployeeNO=‘"+UserName.Text.Trim()+“’”, Connection);
dr = command.ExecuteReader();
while (dr.Read())
{
if ((UserName.Text.Trim() == dr["EmployeeNO"].ToString()) && (PassWord.Text == dr["Password"].ToString()) && (bool)dr["ActiveRecord"] == true)
{
dr.Close();//断开数据库连接
Connection.Close();
Response.Redirect("Report.aspx");
return;
}
}
dr.Close();//断开数据库连接
Connection.Close();
之前已经定义了
SqlConnection Connection;
SqlDataReader dr ;
string strCon = ConfigurationManager.ConnectionStrings["Weekly_ReportConnectionString203"].ToString(); //SQL连接字段 |