|
|
|
แนะนำวิธีตรวจสอบรหัสพนักงานเพื่อนเข้าหน้าตามสิทธิผู้ใช้ ASP.NET C# หน่อยค่ะ |
|
|
|
|
|
|
|
ใช้พวก DataTable ครับ
Code (C#)
{
String strConnString;
strConnString = "Server=localhost;UID=sa;PASSWORD=12345;database=mydatabase";
objConn = new System.Data.SqlClient.SqlConnection(strConnString);
objConn.Open();
String strSQL;
strSQL = " SELECT * FROM Register WHERE UserName = '" + this.txtUsername.Text + "' AND [Password] = '" + this.txtPass.Text + "' ";
dtAdapter = new System.Data.SqlClient.SqlDataAdapter(strSQL, objConn);
dtAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["strUserID"] = dt.Rows[0]["UserID"].ToString();
Session["strUser"] = this.txtUsername.Text;
if (Session["Status"] == "ADMIN")
{
Response.Redirect("ADMIN.aspx");
}
else
{
Response.Redirect("USER.aspx");
}
}
else
{
this.lblStatus.Visible = true;
this.lblStatus.Text = "กรุณาตรวจสอบ Username&Password!!";
}
dtAdapter = null;
objConn.Close();
objConn = null;
}
|
|
|
|
|
Date :
2014-02-10 06:25:23 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|