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
username=
@username and password=
@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
Also send me a cc of ur msg to santhosh.vkumar@gmail.com
Comments
Response.Redirect(dr["permission"].ToString() + ".aspx");
Hope that helps !!
Techie
========================================================
We make a living by what we get, but we make a life by what we give.
::: Winston Churchill :::