First we have to create a database for storing the login information
Open the Sqlserver Management studio
Create a new database and change the database name as db_Logininformation
Create a New table in that database(db_Logininformation) and change the table name as tab_userinformation
Now, create the following fields
and save the table
Next ,open the Microsoft visual studio 2008
Next,select the Aspnet web application and change the name as LoginPage
Next,come to the design page of LoginPage and drag and drop two labels,two textboxes and button
next,come to the code page of the Login.aspx.cs
Write the following codein the page event
Open the Sqlserver Management studio
Create a new database and change the database name as db_Logininformation
Create a New table in that database(db_Logininformation) and change the table name as tab_userinformation
Now, create the following fields
- UserID int PrimaryKey
- username varchar(50)
- Password varchar(50)
and save the table
Next ,open the Microsoft visual studio 2008
Next,select the Aspnet web application and change the name as LoginPage
Next,come to the design page of LoginPage and drag and drop two labels,two textboxes and button
next,come to the code page of the Login.aspx.cs
Write the following codein the page event
- protected void Button1_Click(object sender, EventArgs e)
- {
- con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ToString());
- con.Open();
- com = new SqlCommand("select Password from userinformation where Username='" + txt_uname.Text + "'", con);
- dr = com.ExecuteReader();
- if (!dr.Read())
- {
- Response.write("Invalid User");
- }
- else
- {
- if (dr[0].ToString() == txt_pwd.Text)
- {
- Response.Redirect("~/mainPage.aspx");
- }
- else
- {
- Response.write("Wrong Password");
- txt_pwd.Focus();
- }
- }
- }
No comments:
Post a Comment
Please Provide your feedback here