Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Btnlogin_Click(object sender, EventArgs e)
- {
- //when you noticed..I split dbprovider and dbsource,
- //actually you can combined them without having
- //concatenation.
- string dbProvider = "PROVIDER = Microsoft.Jet.OLEDB.4.0;";
- string dbSource = "Data Source = C:\\account.mdb";
- OleDbConnection con = new OleDbConnection(dbProvider + dbSource);
- string sql = "SELECT * FROM tblaccount WHERE Username = '" + txtusername.Text +
- "' AND Password = '" + txtpassword.Text +
- "' AND UserLevel = '" + DropDownList1.Text + "'";
- OleDbCommand cmd = new OleDbCommand(sql, con);
- con.Open();
- OleDbDataReader sdr = cmd.ExecuteReader();
- string userlevel; //variable declaration for the user
- userlevel = DropDownList1.SelectedItem.Text.ToString();
- if (sdr.HasRows == true) //determine if the data has rows
- {
- switch (userlevel)//reads the username if it is equal to the given username
- {
- case "User"://if sprint username was input, Loginforsprint.asp web form
- Response.Redirect("~/Loginforuser.aspx");
- break;
- case "Admin":
- Response.Redirect("~/Loginforadmin.aspx");
- break;
- }
- }
- else
- {
- lblerror.Text = "Invalid data!!";
- }
- }
Add Comment
Please, Sign In to add comment