Connection string in Web.config

G

GaryB

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
 
S

Steven Cheng[MSFT]

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/default.asp?url=/library/en-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
 
G

GaryB

Steven,
Thanks. That clears up the issue. It turns out that our <appsettings
section of the web.config had become corrupted.
Gary
 
S

Steven Cheng[MSFT]

You're welcome Gary.

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


Regards,

Steven Cheng
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top