Hi all,
Today I tried to design a login page of my own. Which contains
username and password. In database SQL I hav 3 column username,
password, permission. What I exactly need is I need to redirect to the
page under the name of permission if user name and password get
matches. So I tried the following coding.
con = new SqlConnection();
string xx;
con.ConnectionString = "Data Source=santhosh;Initial
Catalog=ec;User ID=sa;Password=test";
con.Open();
SqlCommand cmd = new SqlCommand();
cmd = con.CreateCommand();
cmd.CommandText = "select username, password from logi where
userna...@username and passwo...@password";
cmd.Parameters.Add("@username", SqlDbType.VarChar);
cmd.Parameters["@username"].Value = TextBox1.Text;
cmd.Parameters.Add("@password", SqlDbType.VarChar);
cmd.Parameters["@password"].Value = TextBox2.Text;
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Redirect(dr["permission"+".aspx"].ToString());
}
else
MessageBox.Show("buzz");
But this Response.Redirect(dr["permission"+".aspx"].ToString());--- is
not working it shows array out of bound exception what I have to do
now.
Thanks in Advance,
Santhosh V Kumar