I uploaded my site on godaddy shared host. I can access this database from my management studio. I can't access this database from my site. I get following error:
Format of the initialization string does not conform to specification starting at index 0.
My connection string is in web.config and it looks like this:
<connectionStrings>
<add name="mcn" connectionString="Data Source=mydatabase.db.8706856.hostedresource.com; Initial Catalog=mydatabase; User ID=username; Password=xyz;" providerName="System.Data.SqlClient" />
</connectionStrings>
What cause this error? I have also tried to write ...Data Source=(local);...
Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.
The connection string should be added to your application's App. config file (Web. config if you are using ASP.NET). If your connection string contains sensitive information, such as username and password, you can protect the contents of the configuration file using Protected Configuration.
Connection String is a normal String representation which contains Database connection information to establish the connection between Database and the Application.
It might help to see what the actual connection string is. Add to Global.asax:
throw new Exception(ConfigurationManager.ConnectionStrings["mcn"].ConnectionString);
If the actual connection string is $(ReplacableToken_mcn-Web.config Connection String_0)
, that would explain the problem.
I was facing the same problem and found out that my connection string had an extra double-quote character in the middle of the connection string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With