Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format of the initialization string does not conform to specification starting at index 0

I have an ASP.Net MVC application which runs fine on my local development machine. But when deployed to IIS7 gives the following error when trying to log in:

Format of the initialization string does not conform to specification starting at index 0

Most people who post this error resolve it by changing their connection string in some way. However my connection string on the local and deployed application are the same. The connection string is like this:

<add name="ApplicationServices" connectionString="Data Source=*server*\*instance*;Initial Catalog=*database*;Integrated Security=True;"
      providerName="System.Data.SqlClient" />

What is causing this error in my case?

like image 839
Banford Avatar asked Mar 07 '11 12:03

Banford


2 Answers

Format of the initialization string does not conform to specification starting at index 0

Web.config :

<connectionStrings>
    <add name="TestDataConnectionString" connectionString="Data Source=.\SQLExpress;Initial Catalog=TestData;User ID=satest;Password=satest"
     />
  </connectionStrings>

In aspx.cs Page the code must be written in the below format :

SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["TestDataConnectionString"].ToString());
like image 61
Guru Avatar answered Sep 19 '22 05:09

Guru


Web Deployment tool created wrong line in config when I checked Enable CodeFirst Migrations check-box.

like image 28
Der_Meister Avatar answered Sep 20 '22 05:09

Der_Meister