Summary (5)-a character in the password of the web. config database connection string causes database connection failure

Source: Internet
Author: User
Tags management studio sql server management sql server management studio

Previously, when I was using vs2003 for development, I changed the database SA password to cbmin12 & 8 in SQL server2005 and used SQL Server Management studio to connect to the database. Everything was normal. However, when I configure the Web. config database connection string in the vs2003 project, the connection to the database prompts logon failure.

(This problem has been improved in vs2008. If you type "&" in Web. config, an error warning will be prompted immediately .)

Failed to find the cause for a long time, helpless, try to change the password, change the password to cbmin1278, the test connection is successful. Therefore, suspicious characters may be the cause of database connection failure. After querying the data, we found that the name of & in XML is invalid. Web. config is also an XML file. Therefore, & characters cannot be used as passwords in Web. config. Therefore, avoid using such characters when setting passwords. These characters also include <,>, ', and.

In order to reduce errors, it is better to use entities, and the corresponding entities predefined in the XML document:

& Lt; <Yu no.

& Gt;> greater

& Amp; & and

& Apons; 'single quotes

& Quot; "Double quotation marks

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.