This article mainly introduces the asp.net using the ODP-Oracle connection method of the anti-injection login verification program, the need for friends can refer to the
There are a lot of SQL connections on the Internet login authentication, but no Oracle connection way, I groped a morning to write this executable function, share to everyone
The code is as follows:
User Login Check
public bool Logincheck (string f_loginname, String f_loginpass)
{
BOOL result = FALSE;
Regular expression checking
if (Regex.IsMatch (f_loginname,@ "^[a-za-z0-9]{1,15}$") && Regex.IsMatch (f_loginpass,@ "^[a-za-z0-9]{1,15}$" ))
{
OracleConnection objconn = new OracleConnection (configurationmanager.connectionstrings["ConnectionString"). ConnectionString);
OracleCommand objcmd = new OracleCommand ("SELECT * from USERS where username=:p username and password=:p password", objconn) ;
OBJCMD.PARAMETERS.ADD ("Pusername", oracledbtype.varchar2). Value = F_loginname;
OBJCMD.PARAMETERS.ADD ("Ppassword", oracledbtype.varchar2). Value = F_loginpass;
objConn.Open ();
OracleDataReader OBJDR = Objcmd.executereader ();
Read content
if (Objdr.read ())
{
result = true;
}
Close Database
Objdr.close ();
Objconn.close ();
}
return result;
}
Note : Please pay attention to the triple Programming Tutorials section for more wonderful articles .