using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Data; namespace Datile { public partial class login : System.Web.UI.Page { public static string s = System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationDbContext"].ToString(); SqlConnection con = new SqlConnection(s); protected void Page_Load(object sender, EventArgs e) { } protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if ((TextUname.Text != "") && (TextPassword.Text != "")) { con.Open(); SqlCommand cmd = new SqlCommand("select * from login where username='" + TextUname.Text + "'", con); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { if (TextUname.Text == dr["username"].ToString()) { if (TextPassword.Text == dr["password"].ToString()) { Session["name"] = dr["username"].ToString(); Session["uid"] = dr["uid"].ToString(); } else { // if (TextBox2.Text != dr["pwd"].ToString()) Label3.Text = "Incorrect Password"; } } else if (TextUname.Text != dr["username"].ToString() && TextPassword.Text != dr["password"].ToString()) { Label3.Text = "both UserName and Password are wrong"; } else { Label3.Text = "Incorrect UserName "; } } else { Label1.Text = "both UserName and Password are wrong"; } dr.Close(); con.Close(); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)