Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix error ::Format of the initialization string does not conform to specification starting at index 0::

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);...

like image 604
1110 Avatar asked Jan 27 '12 21:01

1110


People also ask

How do I find the connection string in SQL Server?

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.

Where do I put connection string in asp net core?

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.

What is data source in connection string in C#?

Connection String is a normal String representation which contains Database connection information to establish the connection between Database and the Application.


2 Answers

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.

like image 196
Michael Liu Avatar answered Sep 28 '22 22:09

Michael Liu


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.

like image 45
dotNET Avatar answered Sep 28 '22 23:09

dotNET