The purpose of this logindemo is to practice accessing the database, using stored procedures, and finally writing a user class.
Page composition: default.aspx,logsuccess.htm,logfailure.htm
Database test, table User:userid (self-increasing), Username,password
Front Desk: A simple landing interface
Background code:
1, long time ago to do the first example of the time used:
Code
protected void CheckAccount()
{
string strConn = "server=localhost;uid=sa;pwd=123;database=test;";
SqlConnection conn = new SqlConnection(strConn);
String strComm = "Select * from Users where UserName ='" + UserName.Text + "' and PassWord= '" + PassWord.Text + "'";
SqlCommand comm = new SqlCommand(strComm, conn);
conn.Open();
SqlDataReader dr = comm.ExecuteReader();
if (dr.Read())
{
Response.Redirect("LogSuccess.htm");
}
else
{
Response.Redirect("LogFailure.htm");
}
conn.Close();
}