Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Connection string in Web.config

Reply
Thread Tools

Connection string in Web.config

 
 
GaryB
Guest
Posts: n/a
 
      10-01-2004
In a large asp.net project we have always kept our connection string in the
Web.config as so....

<appSettings>
<!-- User application and configured property settings go here.-->
<!-- Example: <add key="settingName" value="settingValue"/> -->

<add key="connCP.ConnectionString" value=" blah, blah, blah......

When adding and modifying dataadapters in vs.net on a design page we could
always expand (DynamicProperties) and see our connCP there where we could
assign it as our connectionstring for the dataadapter. It all worked just
fine.

Now, for some reason it's not there anymore. we have to go in and modify
the standard SQLConnection each time.

What could have caused this to stop working?

Thanks,

G


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-04-2004
Hi Gary,

As for the dynamic properties on those certain Components, that're stored
in the Application's Config file(web.config for asp.net web application).
And all the items's values must be retrieved via runtime code. The VS.NET
IDE only help you generate such code. For example, when we check the
sqlConnection's connectionstring property to be mapped to a key in the
web.config, the ide will generate the following code in the webform page's
initalizecomponent() method:

================
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new
System.Configuration.AppSettingsReader();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
.............................
========================


So you can have a check to see whether the code is generated correctly. In
fact, regardless of the vs.net, we can all add the following code ourself.
And this makes the component's certain dynamic property be intialized by
the mapped value in the config file.

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtsksettingdynamicproperty.asp

Hope helps. If you have any other questions, please feel free to post here.
Thanks.


Regards,

Steven Cheng
Microsoft Online Support

 
Reply With Quote
 
 
 
 
GaryB
Guest
Posts: n/a
 
      10-04-2004
Steven,
Thanks. That clears up the issue. It turns out that our <appsettings
section of the web.config had become corrupted.
Gary

"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Gary,
>
> As for the dynamic properties on those certain Components, that're stored
> in the Application's Config file(web.config for asp.net web application).
> And all the items's values must be retrieved via runtime code. The VS.NET
> IDE only help you generate such code. For example, when we check the
> sqlConnection's connectionstring property to be mapped to a key in the
> web.config, the ide will generate the following code in the webform page's
> initalizecomponent() method:
>
> ================
> private void InitializeComponent()
> {
> System.Configuration.AppSettingsReader configurationAppSettings = new
> System.Configuration.AppSettingsReader();
> this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
> ............................
> ========================
>
>
> So you can have a check to see whether the code is generated correctly. In
> fact, regardless of the vs.net, we can all add the following code ourself.
> And this makes the component's certain dynamic property be intialized by
> the mapped value in the config file.
>
> http://msdn.microsoft.com/library/de...us/vbcon/html/
> vbtsksettingdynamicproperty.asp
>
> Hope helps. If you have any other questions, please feel free to post
> here.
> Thanks.
>
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      10-05-2004
You're welcome Gary.

Glad that the problem is got resolved. Have a good day!


Regards,

Steven Cheng
Microsoft Online Support

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the connection pool size in the Sybase connection string? Wei Lu ASP .Net 2 02-16-2009 09:51 AM
Web.config: connection string or connection key? rlueneberg@gmail.com ASP .Net 3 08-03-2007 09:37 PM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= ASP .Net 2 10-26-2004 02:43 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM
connection string exception : Format of the initialization string does not conform to specification starting at index 0 Gaurav ASP .Net 0 11-07-2003 10:24 AM



Advertisments