usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data.SqlClient;usingSystem.Data.Sql;usingSystem.Data; Public Partial class_default:system.web.ui.page{protected voidPage_Load (Objectsender, EventArgs e) { } protected voidLogin1_authenticate (Objectsender, AuthenticateEventArgs e) { //gets the property value on the login control stringStdxh =Login1.username; stringPassword =Login1.password; //generating SQL statements and Parameter objects stringsql ="Select COUNT (*) from stdinfo where [email protected] and [email protected]"; sqlparameter[] param={ NewSqlParameter ("@stdXh", SqlDbType.Char),NewSqlParameter ("@stdMm", SqlDbType.VarChar)}; param[0]. Value =Stdxh; param[1]. Value =password; //Execute SQL statement intUserCount = ((int) (Sqlhelp.executescalar (sqlhelp.connectionstringlcaltransaction, CommandType.Text, SQL, param)); //determine if landing is successful if(UserCount >0) {e.authenticated=true;//Set Login judgment variables//If the login is successful, the study number will be saved in the session for the subsequent score query page readsession["Stdxh"] =Stdxh; } Elsee.authenticated=false;//Set Login judgment variables }}
Login Control Overloaded Login method