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

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:

publicstaticstring 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;

}

returnnull;

}

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.

[3713 byte] By [KeithSmith] at [2007-12-24]
# 1

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?

BillLin-MSFT at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
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?
alazela at 2007-8-31 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified