protected void Button1_Click(object sender, EventArgs e)
{
int i=0;
SqlConnection con = new SqlConnection("server=YASH-BA85E3332D\\SQLEXPRESS;database=db_dda;trusted_connection=yes;");
SqlCommand cmd =new SqlCommand("select * from adm_login",con);
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds);
string dlogin;
string dpassword;
int lrecord;
dlogin = ds.Tables[0].Rows[i]["adm_id"].ToString();
dpassword = ds.Tables[0].Rows[i]["adm_pwd"].ToString();
lrecord = ds.Tables[0].Rows.Count;
while (i < lrecord)
{
if (TextBox1.Text == dlogin && TextBox2.Text == dpassword)
{
Response.Redirect("admin_pages\\admin_main_page.aspx");
return;
}
else
{
i++;
if (i < lrecord)
{
dlogin = ds.Tables[0].Rows[i]["adm_id"].ToString();
dpassword = ds.Tables[0].Rows[i]["adm_pwd"].ToString();
}
else
{
Label3.Text="Invalid User id or Password";
}
}
}
}
No comments:
Post a Comment