.NET entry some common things

xiaoxiao2021-03-06  50

/ / According to the username and password verification

Private Int CheckUserandPwd (String Usercode, String Userpwd)

{

SqlConnection Objconn = New SqlConnection (ConfigurationSttings.AppSettings ["Connectionstring"]);

Objconn.open ();

// call usp_checkuserlogin

SQLCommand Objcomm = New Sqlcommand ("USP_CHECKUSERLOGIN", OBJCONN);

Objcomm.commandtype = commandtype.storedprocedure;

// Add a USP parameter

Objcomm.Parameters.Add (New Sqlparameter ("@ Usercode", UserCode);

Objcomm.Parameters.Add ("@ pwd", userpwd);

/ / Receive USP return value

Objcomm.Parameters.Add (New Sqlparameter ("RetValue", Sqldbtype.int, 4, ParameterDirection.ReturnValue,

False, 0, 0, String.empty, DataRowVersion.default, null);

Objcomm.executenonQuery ();

INT USPRETURNVALUE = (int) objcomm.Parameters ["RetValue"]. Value;

Objconn.close ();

Return USPRETURNVALUE;

}

// login processing

Private void login_click (object sender, system.web.ui.imageClickeventargs E)

{

INT uspreturnValue = checkuserandpwd (usercode.text, password.text);

IF (USPRETURNVALUE == -1)

{

Response.write (@ "