none
Err: Format of the initialization string does not conform to specification starting at index 0.

    Question

  • The Error Stack is:

    System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0. at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at Custom.Data.SqlConnectionHelper.GetConnection(String connectionstring) at Custom.Data.SqlConnectionHelper.GetCommand(String NamedConnection) at Custom.Security.User.GetUsersDefaultFacility(String username) at Custom.Web.WebParts.ReportingWebPart.RenderWebPart(HtmlTextWriter output)

    My connection string in web.config:

    <add name="aspnetdb" connectionString="Server=myserver;Database=aspnetdb;Trusted_Connection=True;" />

    I have read the previous post here with teh same error, but it did not solve my issue.

    The code for getting the connectionstring from the web.config is:

    public static string GetConnectionString(string NamedConnection)

    {

    string text1 = null;

    System.Configuration.ConnectionStringSettings settings1 = System.Configuration.ConfigurationManager.ConnectionStrings[NamedConnection];

    //ConnectionStringSettings settings1 = ConfigurationManager.ConnectionStrings["LocalSqlServer"];

    if (settings1 != null)

    {

    text1 = settings1.ConnectionString;

    }

    if (text1 != null)

    {

    return text1;

    }

    return null;

    }

     

    After I get the connection string form the SettingsManager, I write out the string in debug, and it looks fine. I then try to create a Connection off it, and kaboom! This code works on my Virtual Machine (Win 03 Svr) and local box (XP), but not the developer server (Win 03 EE).

    The code is a WebPart, running in Microsoft Sharepoint Services 3.0.

    Tuesday, September 19, 2006 3:15 PM

Answers

All replies

  • How do you create the connection with the string you got from the SettingsManager?

    It looks similar to the issue in http://support.microsoft.com/kb/823679/

    Have you applied the patch?

     

    Wednesday, September 20, 2006 7:06 PM
  • SqlClient should accept the format you've posted from your config file (I just tried the same format with no problems).  Can you break on the exception in a debugger and see what string was actually passed to the connection?
    Wednesday, September 20, 2006 7:06 PM