473,320 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Connection string in Web.config

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
Nov 18 '05 #1
3 5102
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

Nov 18 '05 #2
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]" <v-******@online.microsoft.com> wrote in message
news:ri**************@cpmsftngxa06.phx.gbl...
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

Nov 18 '05 #3
You're welcome Gary.

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

Steven Cheng
Microsoft Online Support

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Varun | last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file. i want to write a method in a common layer where i can retrieve...
6
by: H | last post by:
This is a question that has haunted me for quite some time. if you build a 4 tier database application where the 4th tier is the database server (MS SQL 2000), where do you build the connection...
6
by: Jon Davis | last post by:
I like the drag-and-drop accessibility of dragging a table to a Web Forms designer and seeing a SqlDataAdapter automatically created for me.. being able to create a DataSet from that is fun and...
6
by: Mike L. | last post by:
Hi, Pls, beware that I'm new to this :) I've developed several web appl, either with ASP or ASP.NET. All using SQL server as the back end. In my development environment, I have a single...
19
by: Jaime Stuardo | last post by:
Hi all.. I have created a business logic component that is used from my ASP.NET webform. It works, but connection string to the database is hard coded, as in this method : public DataSet...
14
by: WebMatrix | last post by:
Hello, I have developed a web application that connects to 2 different database servers. The connection strings with db username + password are stored in web.config file. After a code review,...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
2
by: Thorsten Dittmar | last post by:
Hi, I don't get it. I'm using a typed dataset with table adapters and all that stuff. I have the database server running locally on my development system. Now: when creating a tableadapter...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
2
by: Johnson | last post by:
I'm trying to fix a "sub optimal" situation with respect to connection string management. Your thoughtful responses will be appreciated. I just started with a new client who has a bunch of legacy...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.