Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

coding for login page in ado.

net
i want a coding or a design page for a login page in which where we are already
make a database or we are already inserted the value of username or password
in our database when we want to login in the runtime we have to inserted those
value which are already in the database

using
using
using
using
using
using
using
using
using
using
using
using

System;
System.Configuration;
System.Data;
System.Data.SqlClient;
System.Linq;
System.Web;
System.Web.Security;
System.Web.UI;
System.Web.UI.HtmlControls;
System.Web.UI.WebControls;
System.Web.UI.WebControls.WebParts;
System.Xml.Linq;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
}
protected string Getconnection()
{

return
System.Configuration.ConfigurationManager.ConnectionStrings["subhacon"].ConnectionString;
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(Getconnection());
con.Open();
SqlCommand com = new SqlCommand("select * from login where uname= @uname and pass=
@pass", con);

com.Parameters.AddWithValue("@uname", TextBox1.Text);
com.Parameters.AddWithValue("@pass", TextBox2.Text);
if(con!=null)
Response.Write("conn success");
SqlDataReader dr = com.ExecuteReader();
if (dr.Read()==true)
{
Response.Redirect("http://google.com");
Response.Write("login success");
}
else
Response.Write("login failed");
}
catch (Exception ex)
{
Response.Write("error");
}

}
}

You might also like