Solved

Passing the connection string in my web.config to my Data Access Project

Posted on 2006-10-30
2
243 Views
Last Modified: 2010-04-23
I have created a website. My website web.config is storing the connection string to the database. I also have 2 additional class library projects MyWebisteBLL(Business Logic) and MyWebsiteDAL(Data Access Layer).  In my DAL the app.config is storing the connection string for this project.  What is the proper way for the DAL to reference the connection string from the web.config.
0
Comment
Question by:DigitalDan3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Shakti109 earned 500 total points
ID: 17835868

Are these DLL libraries separate objects as in they are compiled out to true .DLL's and then these .DLL's are referenced in your web project, OR are they just classes you have created in the single web project.

If they are truly separate .DLL's that are then referenced by your root web project, you will need to add the same .config file as a resource to the .DLL.

If they are just classes within the single web-project then you can reference it directly.

Something along the lines of :

Private oDatasource as string
Private aConfig As System.Configuration.ConfigurationSettings
oDatasource = aConfig.AppSettings("DataSource")

This assumes the key in your .config file is named "DataSource".
0
 

Author Comment

by:DigitalDan3
ID: 17837694
These are separate projects that I created in my website solution.  They are DLL's in my Bin folder and their connection string is stored in .config file of the project.  How can I make these DLL's use the connection in the web.config.  I am using the new membership API in VS2005.  The membership API and the Data are on the same database.  I was trying to avoid changing the connection string in 2 different places as I will be working against the live and development data.

Thanks

Dan
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question