Asp.net uses the ODP (oracle connection mode) to prevent injection of Logon verification programs

Source: Internet
Author: User

There are a lot of SQL Connection Methods for login verification on the Internet, but there is no oracle connection method. I found out this executable function one morning and shared it with you.
Copy codeThe Code is as follows:
// User Logon check
Public bool LoginCheck (string f_LoginName, string f_LoginPass)
{
Bool result = false;
// Regular Expression check
If (Regex. isMatch (f_LoginName, @ "^ [a-zA-Z0-9] {} $") & Regex. isMatch (f_LoginPass, @ "^ [a-zA-Z0-9] {} $ "))
{
OracleConnection objConn = new OracleConnection (ConfigurationManager. ConnectionStrings ["ConnectionString"]. ConnectionString );
OracleCommand objCmd = new OracleCommand ("select * from USERS where username =: pUserName and password =: pPassWord", 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 the database
ObjDr. Close ();
ObjConn. Close ();
}
Return result;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.