P
Patrick.O.Ige
I have a code below.(It validates against a SQL DB(login page).thats is
giving me an error!
When i try to use :- Session["name"] = dr["username.Text"].ToString();
To catch the username so as to redirect the user logged in to another
page....PRINTING
Hello:- John .. for example
It says ERROR:- System.IndexOutOfRangeException: username.Text
What does this mean and how can i correct it
PLS HELP!!
Thx
void Login_Click(Object sender, EventArgs e)
{
SqlDataReader dr;
SqlConnection cn = new SqlConnection("Data Source=(local);Initial
Catalog=Northwind;Integrated Security=SSPI;");
cn.Open();
SqlCommand cmdQuestion = new SqlCommand("SELECT Password FROM Users WHERE
username = '" + username.Text + "'", cn);
dr=cmdQuestion.ExecuteReader();
if(dr.Read())
if(dr["Password"].ToString() == Password.Text)
// CookieAuthentication.RedirectFromLoginPage(Email.Text, false);
Response.Redirect("testlabel.aspx");
else
Msg.Text = "Invalid password.";
else
Msg.Text = "Email address not found.";
//Session["name"] = dr["username.Text"].ToString();
cn.Close();
}
giving me an error!
When i try to use :- Session["name"] = dr["username.Text"].ToString();
To catch the username so as to redirect the user logged in to another
page....PRINTING
Hello:- John .. for example
It says ERROR:- System.IndexOutOfRangeException: username.Text
What does this mean and how can i correct it
PLS HELP!!
Thx
void Login_Click(Object sender, EventArgs e)
{
SqlDataReader dr;
SqlConnection cn = new SqlConnection("Data Source=(local);Initial
Catalog=Northwind;Integrated Security=SSPI;");
cn.Open();
SqlCommand cmdQuestion = new SqlCommand("SELECT Password FROM Users WHERE
username = '" + username.Text + "'", cn);
dr=cmdQuestion.ExecuteReader();
if(dr.Read())
if(dr["Password"].ToString() == Password.Text)
// CookieAuthentication.RedirectFromLoginPage(Email.Text, false);
Response.Redirect("testlabel.aspx");
else
Msg.Text = "Invalid password.";
else
Msg.Text = "Email address not found.";
//Session["name"] = dr["username.Text"].ToString();
cn.Close();
}