|
 |
|
asp.net c# ต้องการใช้ session เก็บค่า memberID ,name ในตาราง Member จะเขียนยังไงหรอครับ |
|
 |
|
|
 |
 |
|
Code (C#)
//*** Open Connection ***'
strConnString = "Server=localhost;UID=sa;PASSWORD=;database=mydatabase;Max Pool Size=400;Connect Timeout=600;";
objConn = new SqlConnection();
objConn.ConnectionString = strConnString;
objConn.Open();
//*** Check Login ***'
strSQL = new StringBuilder();
strSQL.Append(" SELECT COUNT(*) FROM member ");
strSQL.Append(" WHERE Username = @sUsername ");
strSQL.Append(" AND Password = @sPassword ");
objCmd = new SqlCommand(strSQL.ToString(), objConn);
objCmd.Parameters.Add("@sUsername", SqlDbType.VarChar).Value = this.txtUsername.Text;
objCmd.Parameters.Add("@sPassword", SqlDbType.VarChar).Value = this.txtPassword.Text;
intCount = (int)objCmd.ExecuteScalar();
objConn.Close();
objConn = null;
if (intCount <= 0)
{
this.lblStatus.ForeColor = System.Drawing.Color.Red;
this.lblStatus.Text = "Username or Password wrong!";
}
else
{
Session["strUsername"] = this.txtUsername.Text;
Response.Redirect("frmHomeProfile.aspx");
}
ASP.NET Register / Login Form / Reset Password / Update Profile (VB.NET , C#)
|
 |
 |
 |
 |
Date :
2012-12-15 08:22:53 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|