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

后端 未结 18 1895
一向
一向 2020-11-30 11:04

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

相关标签:
18条回答
  • 2020-11-30 11:51

    In my Case, it is because of having more than one connection string in your Solution. one for your current project and the other one for a startup project in your Solution. for more information please refer to Telerik report not working

    here we have the same situation.

    0 讨论(0)
  • 2020-11-30 11:52

    For my case, the culprit was the semicolon and double quotes in the password for prod DB. Our IT team use some tool to generate passwords, so it generated one with the semicolon and double quotes Connectionstring looks like

    <add key="BusDatabaseConnectionString" value="Data Source=myserver;Initial Catalog=testdb;User Id=Listener;Password=BlaBla"';[]qrk/>
    

    Got the password changed and it worked.

    0 讨论(0)
  • 2020-11-30 11:53

    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.

    0 讨论(0)
  • 2020-11-30 12:01

    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.

    0 讨论(0)
  • 2020-11-30 12:04

    I originally was calling the connection string value as shown below (VB.NET) and got the error being mentioned

     Using connection As New SqlConnection("connectionStringName") 
      '// more code would go here...
     End Using
    

    adding a reference to System.Configuration and updating my code as shown below was my solution. The connection string was not the problem since others controls used it without any issues (SqlDataSource)

    Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("connectionStringName").ConnectionString)
        '// more code would go here...
    End Using
    
    0 讨论(0)
  • 2020-11-30 12:04

    Another pitfall is that connectionString sometimes refers to the name of the connection string in the app/web-config and sometimes to the actual connection string itself and vice versa.

    Very easy to fix but sometimes hard to spot.

    0 讨论(0)
提交回复
热议问题