Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
5
Answers
if statement c# & sql...
Mufid Bagdadi
8y
360
1
Reply
Following is my code my requirement is after if my password is rpgls007 it should redirect to particular page else to other page when data is read from database,
con.Open();
string strQuery = "select * from empData where empid = @username and password = @password";
SqlCommand cmd = new SqlCommand(strQuery);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@username", txtuser.Text.Trim());
cmd.Parameters.AddWithValue("@password", txtpassword.Text.Trim());
cmd.Connection = con;
dr = cmd.ExecuteReader();
if (dr.Read())
{
if (txtpassword.Text != "rpgls007")
{
Session["user"] = txtuser.Text;
Response.Redirect("
user/user.aspx
");
}
else
{
Session["user"] = txtuser.Text;
Response.Redirect("
user/password.aspx
");
}
}
else
{
lbl_msg.Text = "Incorrect User or Password";
resetPassword.Visible = true;
lbl_msg.Visible = true;
}
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
how to print 20 records in a page using crystal reports
Publish RemoteApp through Powershell Script in C#