add following on web config...here enter your server name, databse name, etc.
<connectionStrings>
<add name="dbcon" connectionString="server=RUDRA-PC\SQLEXPRESS;uid=sa;pwd=123456;database=library;"/>
</connectionStrings>
on button click....
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string str1 = "select * from signup where username='" + TextBox1.Text + "' and password ='" + TextBox2.Text + "'";
String con = ConfigurationManager.ConnectionStrings["dbcon"].ConnectionString;
SqlConnection con1 = new SqlConnection(con);
con1.Open();
SqlDataAdapter da1 = new SqlDataAdapter(str1, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
if (ds1.Tables[0].Rows.Count > 0)
{
Session["user"] = TextBox1.Text;
Response.Redirect("home.aspx");
}
else
{
Label4.Text = "INCORRECT PASSWORD/USER NAME!";
}
con1.Close();
}
catch
{
Label4.Text = "DATABASE DOES NOT EXIST";
}
<connectionStrings>
<add name="dbcon" connectionString="server=RUDRA-PC\SQLEXPRESS;uid=sa;pwd=123456;database=library;"/>
</connectionStrings>
on button click....
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string str1 = "select * from signup where username='" + TextBox1.Text + "' and password ='" + TextBox2.Text + "'";
String con = ConfigurationManager.ConnectionStrings["dbcon"].ConnectionString;
SqlConnection con1 = new SqlConnection(con);
con1.Open();
SqlDataAdapter da1 = new SqlDataAdapter(str1, con);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
if (ds1.Tables[0].Rows.Count > 0)
{
Session["user"] = TextBox1.Text;
Response.Redirect("home.aspx");
}
else
{
Label4.Text = "INCORRECT PASSWORD/USER NAME!";
}
con1.Close();
}
catch
{
Label4.Text = "DATABASE DOES NOT EXIST";
}
No comments:
Post a Comment