?
Solved

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

Posted on 2006-10-30
2
Medium Priority
?
246 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 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
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.…
Suggested Courses

765 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