テーブルts_deptからC#で記述された次のSQLクエリを使用してdeptの値を取得しています-いつどのように割り当てるのSession["UserAuthentication"]
です(CurrentName != null)
か?
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string username = Login_Box.UserName;
string pwd = Login_Box.Password;
string strConn;
strConn = WebConfigurationManager.ConnectionStrings["team13ConnectionString"].ConnectionString;
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
string sqlUserName;
sqlUserName = "SELECT dept FROM ts_dept WHERE id=@username AND pass=@pwd";
SqlCommand com = new SqlCommand(sqlUserName, Conn);
com.Parameters.Add("@username", username);
com.Parameters.Add("@pwd", pwd);
string CurrentName;
CurrentName = (string)com.ExecuteScalar();
if (CurrentName != null)
{
Session["UserAuthentication"] = username;
Session.Timeout = 1;
Response.Redirect("Default.aspx");
}
else
{
Session["UserAuthentication"] = "";
}
}