Write the following code in Button click event
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select * from com_register where uname='" + TextBox1.Text + "' AND pass='" + TextBox2.Text + "'", con);
System.Data.DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["login"] = dt.Rows[0][0].ToString();
Response.Redirect("Default.aspx");
}
else
{
System.Windows.Forms.MessageBox.Show("User name or password is wrong", "Information", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select * from com_register where uname='" + TextBox1.Text + "' AND pass='" + TextBox2.Text + "'", con);
System.Data.DataTable dt = new DataTable();
adp.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["login"] = dt.Rows[0][0].ToString();
Response.Redirect("Default.aspx");
}
else
{
System.Windows.Forms.MessageBox.Show("User name or password is wrong", "Information", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
}
}
0 comments:
Post a Comment