Hjr-asp.net:asp.net Controller Logon Registration verification

Source: Internet
Author: User

To introduce a few common questions, SQL Server prompts cannot find one or more components. Please reinstall the application to reinstall the solution

Regedit.exe, start the Registry tool

"Hkey_current_user\software\microsoft\sql Server Management Studio"

Delete Xx.0_config folder

You need to be aware that you need to reinstall SQL Server once you remove it, repair the installation

asp.net operation SQL Server database prompts the user to log on failed, most likely the connection string is wrong, may not be complete, such as no password


The following is a quick way to write login verification for the controller of the ASP.net API

Logon authentication, user name exists, password is correct

   Public DataTable GetLogin (string Username, string password) {password = System.Web.Security.FormsA Uthentication.
            HashPasswordForStoringInConfigFile (password, "MD5");//md5 encrypted DataTable dt = null;
            String sql = null;
                                           Sqlparameter[] cmdParms1 ={new SqlParameter ("@username", username), The new SqlParameter ("@password", password)};//is more so than the direct use of the argument More secure, because when you view the SQL statement, you get @string instead of directly seeing the specific value sql = "SELECT * from G_user_info where u_name= @username and u_password=
            @password ";
            
            DT = sqlhelper.getdatatable (sql, CommandType.Text, CMDPARMS1); if (dt = null) {return tabletools.createtable ("error"), there is no operation database to query, the returned value is not instantiated, is null.
            "); else if (dt.
                     Rows.Count = = 0) {sqlparameter[] cmdParms2 ={                      New SqlParameter ("@username", username),};
                sql = "SELECT * from G_user_info where u_name= @username";
                DT = sqlhelper.getdatatable (sql, CommandType.Text, CMDPARMS2); if (dt. Rows.Count = = 0 {return tabletools.createtable ("error", "The user does not exist.")
                "); else {return tabletools.createtable ("error", "Wrong password.")
                ");
        } return DT; }

Registration verification, whether the user name already exists, the mobile phone number has been registered

        public string Getreg (string username, string password,string phone) {string sql = null;
            DataTable dt = null;
                                       Sqlparameter[] cmdParms1 ={new SqlParameter ("@username", username),
            };
            sql = "SELECT * from G_user_info where u_name= @username";

            DT = sqlhelper.getdatatable (sql, CommandType.Text, CMDPARMS1); if (dt. Rows.Count!= 0) {return "The user has been registered.
            ";
                                       } sqlparameter[] CmdParms2 ={new SqlParameter ("@phone", phone),
            };
            sql = "SELECT * from G_user_info where u_phone= @phone";

            DT = sqlhelper.getdatatable (sql, CommandType.Text, CMDPARMS2); if (dt. Rows.Count!= 0) {return "mobile phone number has been used to register."
            "; } Password = system.weB.security.formsauthentication.hashpasswordforstoringinconfigfile (password, "MD5");

            String result = null;
            String integral = null;
            Random ran = new Random (); int randkey = ran.
            Next (100000, 999999);
            integral = randkey.tostring ();
                                           Sqlparameter[] CmdParms3 ={new SqlParameter ("@username", username), New SqlParameter ("@password", password), new SQL
                                           Parameter ("@phone", phone), New SqlParameter ("@inviteCode", 100),
            New SqlParameter ("@integral", Integral)}; sql = "INSERT into G_user_info (u_name,u_password,u_phone,u_invite_code,u_integral) VALUES (@username, @password, @
            Phone, @inviteCode, @integral) "; Sqlhelper.executescalar (SQL, CommandType.Text, CMDPARMS3);
        Return "registered success"; }


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.