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