Solved

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

Posted on 2006-10-30
2
202 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Asp/Net Validation date Issue 9 37
Crystal Report for VS2013 17 38
Getfiles in vb.net 21 0
Saveas need to save a copy 16 0
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now