how can i solve my error ??
hi..when i run my loging page.. that time my usernm wrong &password fieldis right then its work my loging page.....pls give some help
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Mar 5, 2009, 11:19 AM
Try the following code for your login control:
I have two textbox txtEmployeeID is for userName and txtPIN for password,onclick of submit button execute the following code. In my user table usr_vch_Name field is for userId and usr_vch_Password holds tha password
bool blnFound = false;
SqlConnection sqlCon = null;
Array arrOptions;
int intIndex = 0;
sqlCon = new SqlConnection(ConfigurationManager.AppSettings["con"].ToString());//fetching the connection string from web.config.
sqlCon.Open();
SqlCommand cmd = new SqlCommand("select * from Users where usr_int_Type=1 or usr_int_Type=3 ", sqlCon);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
if (dr["usr_vch_Name"].ToString() == txtEmployeeID.Text)
{
if (dr["usr_vch_Password"].ToString() == txtPIN.Text)
{
blnFound = true;
// SUCCESSFULLY USER VALIDATED
}
}
}
if (!blnFound)
MessageBox.Show("Wrong login info is provided");
txtEmployeeID.Text = "";
txtPIN.Text = "";
dr.Close();
sqlCon.Close();
Rahul Kumar SaxenaPosted Mar 5, 2009, 2:27 AM
Vimal KandasamyPosted Mar 5, 2009, 2:10 AM
hi..
please tel me exactly what is your problem...