In web.config:
<add name="conn" providerName="System.Data.SqlClient" connectionString="Server=SERVERNAME; Initial Catalog=INITIALDB; UID=username; PWD=+abc-def(;" />
I ensured that the username has db_owner role in the INITIALDB, by deleting the database user and recreating it. I ensured that the username password worked, by connecting to the server via SSMS (using the above UID and PWD) and expanding the database.
Any ideas? I’m at my wits end and I cannot change the password assigned to me very easily… I don’t think any of those characters need escaping but clearly there is a problem.
UPDATE:
The error had nothing to do with the password characters. I was getting “Cannot open database … requested by the login. The login failed …” However — the connection worked perfectly when I removed the “Initial Catalog” or “Database” section from the connection string. Turns out that the database had a .MDF filename that was different than the name of the database (e.g. my_db_name and db_name.mdf). Somehow the connection string that specified the Database or Initial Catalog property was unable to connect because of this. Detaching, changing the MDF filename to be consistent, and re-attaching the database actually sorted the problem. Strange, right?
Use the password this way:
"+abc-def(;"like: