Add or set a user to connect to a database

Source: Internet
Author: User

This blog post teaches you how to deal with asp.net's database connection permissions and authorize a connection pass. Encounter various problems and how to solve them.

ASP.. NET Program, open the web. the config file shows the connection string information of the ms SQL Server database. Normally, the connection string is written on the Web. the ConnectionString node in the Config file or the appSettings node.



With the connection information, you can add the login information of the database to the database:




If you download an asp.net program online and want to run it in your Visual studio for learning, such as in Insus.. NET blog download program, if the program is a database, you must recover the database before running. You may also refer to the above method to add login in the database to create connection permissions for asp.net. The following exception message may appear, "'xerror' already exists in the current database ".




This exception occurs because the user has been backed up when the database is backed up. You can refer to the following database recovery. After recovery, you can see the xerror user name.



There are two ways to solve this problem. One is to solve the problem before the exception occurs, and the other is to solve the problem after the exception occurs. Insus. NET: Let's talk about the last one. Exit the dialog box for all exceptions, open the query analyzer, and switch the database to the current database, for example:

 

 

Then, follow these steps:
Http://www.cnblogs.com/insus/archive/2012/03/16/2401666.html



If you execute the above stored procedure and encounter the following error:

 

That's because you haven't added a login name 'xerror' to the database, and you haven't seen a username 'xerror '. Refer to the last animation in this blog post to add users, but the User Mapping step is missing.



The following is a solution before an exception occurs. After you recover the database, go to Security> user> 'xerror' under the database to delete the database, then refer to the first animation method in this blog post to add users. This is OK.




If you do not want to do this, but your database is recovered, you can refer to the following method:



Or, the best way is to modify the web first. for the database connection character of config, use a brand new one. You can change the password without changing it. Then, go to the database and refer to the first animation method in this blog post to add it. It allows asp.net to connect to the database normally.

 

Related Article

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.