using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.SqlClient; // sqli andmebaasiga seotud asjad using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class login : System.Web.UI.Page { //protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) //{ // e.Authenticated = (Login1.UserName.ToLower() == "mati") && // (Login1.Password == "pwd"); //} //protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) //{ // SqlConnection conn = new SqlConnection( // ConfigurationManager. // ConnectionStrings["veebipoebaasConnectionString"]. // ConnectionString); // SqlCommand cmd = new SqlCommand( // "SELECT TOP 1 kasutajanimi FROM kasutajad " + // "WHERE kasutajanimi = @nimi AND parool = @pwd"); // cmd.Parameters.AddWithValue("nimi", Login1.UserName); // cmd.Parameters.AddWithValue("pwd", Login1.Password); // cmd.Connection = conn; // conn.Open(); // object tulemus = cmd.ExecuteScalar(); // conn.Close(); // e.Authenticated = tulemus != null; //} /* protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { kasutajadDataContext rahvas = new kasutajadDataContext(); //var paring = from k in rahvas.kasutajads // where k.kasutajanimi == Login1.UserName.ToLower() && // k.parool == Login1.Password // select k; //e.Authenticated = paring.Count() != 0; var paring = (from k in rahvas.kasutajads where k.kasutajanimi == Login1.UserName.ToLower() && k.parool == Login1.Password select k).FirstOrDefault(); e.Authenticated = paring != null; } */ }