Dear .Netters,

Following is the code from my web.config file
==========
<add key="SqlConnectionA.ConnectionString" value="workstation id=myPC;packet
size=4096;integrated security=SSPI;data source=\"myPC\\myDB\";persist
security info=False;initial catalog=telecomTimeSheet" />
==========

I call this connectionstring in my code behind file like this:
============
this.sqlConnection1.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings.GetValues("SqlConnect
ionA.ConnectionString").ToString();
=============

When I view the file I get the following error:

=========
[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DBConnectionString.GetKeyValuePair(Char[]
connectionString, Int32 currentPosition, String& key, Char[] valuebuf,
Int32& vallength, Boolean& isempty) +942
System.Data.Common.DBConnectionString.ParseInternal(Char[]
connectionString, UdlSupport checkForUdl, NameValuePair& keychain) +116
System.Data.Common.DBConnectionString..ctor(String connectionString,
UdlSupport checkForUdl) +114
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
+13
System.Data.SqlClient.SqlConnectionString.ParseString(String
connectionString) +96
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
+11
ttsheet.timesheet.timeSheetForm.InitializeComponent() +1590
ttsheet.timesheet.timeSheetForm.OnInit(EventArgs e) +13
System.Web.UI.Control.InitRecursive(Control namingContainer) +241
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Control.InitRecursive(Control namingContainer) +179
System.Web.UI.Page.ProcessRequestMain() +174
=========

Any ideas in what I am doing wrong?

SSP

Re: web.config sql connectionstring problem by anouk

anouk
Sat Jul 26 04:28:07 CDT 2003

Drop the GetValues part, just use:

System.Configuration.ConfigurationSettings.AppSettings("SqlConnectionA.Conne
ctionString")

Hope it helps...


"SSP" <ssp@dt.com> wrote in message
news:%23C$1ZA1UDHA.484@TK2MSFTNGP09.phx.gbl...
> Dear .Netters,
>
> Following is the code from my web.config file
> ==========
> <add key="SqlConnectionA.ConnectionString" value="workstation
id=myPC;packet
> size=4096;integrated security=SSPI;data source=\"myPC\\myDB\";persist
> security info=False;initial catalog=telecomTimeSheet" />
> ==========
>
> I call this connectionstring in my code behind file like this:
> ============
> this.sqlConnection1.ConnectionString =
>
System.Configuration.ConfigurationSettings.AppSettings.GetValues("SqlConnect
> ionA.ConnectionString").ToString();
> =============
>
> When I view the file I get the following error:
>
> =========
> [ArgumentException: Format of the initialization string does not conform
to
> specification starting at index 0.]
> System.Data.Common.DBConnectionString.GetKeyValuePair(Char[]
> connectionString, Int32 currentPosition, String& key, Char[] valuebuf,
> Int32& vallength, Boolean& isempty) +942
> System.Data.Common.DBConnectionString.ParseInternal(Char[]
> connectionString, UdlSupport checkForUdl, NameValuePair& keychain) +116
> System.Data.Common.DBConnectionString..ctor(String connectionString,
> UdlSupport checkForUdl) +114
> System.Data.SqlClient.SqlConnectionString..ctor(String
connectionString)
> +13
> System.Data.SqlClient.SqlConnectionString.ParseString(String
> connectionString) +96
> System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
> +11
> ttsheet.timesheet.timeSheetForm.InitializeComponent() +1590
> ttsheet.timesheet.timeSheetForm.OnInit(EventArgs e) +13
> System.Web.UI.Control.InitRecursive(Control namingContainer) +241
> System.Web.UI.Control.InitRecursive(Control namingContainer) +179
> System.Web.UI.Control.InitRecursive(Control namingContainer) +179
> System.Web.UI.Page.ProcessRequestMain() +174
> =========
>
> Any ideas in what I am doing wrong?
>
> SSP
>
>