https://www.c-sharpcorner.com/article/how-to-create-login-page-in-asp-net-web-application-using-c-sharp-and-sql-server/
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString());
string uid = TextBox1.Text;
string pass = TextBox2.Text;
con.Open();
string qry = "select * from Vendorlogin where UserId='" + uid + "' and Password='" + pass + "'";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
//Label1.Text = "Login Sucess......!!";
Response.Redirect("http://XYZ.co/");
}
else
{
Label1.Text = "UserId & Password Is not correct Try again..!!";
Label1.ForeColor = System.Drawing.Color.Red;
}
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ToString());
string uid = TextBox1.Text;
string pass = TextBox2.Text;
con.Open();
string qry = "select * from Vendorlogin where UserId='" + uid + "' and Password='" + pass + "'";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
//Label1.Text = "Login Sucess......!!";
Response.Redirect("http://XYZ.co/");
}
else
{
Label1.Text = "UserId & Password Is not correct Try again..!!";
Label1.ForeColor = System.Drawing.Color.Red;
}
con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
No comments:
Post a Comment