Setting ConnectionString when creating a data access layer with datasets

D

daokfella

In my solution, I have a project that is my data access layer. This
layer simply consists of strongly-typed datasets created by dragging
tables from the server explorer into the dataset designer. The
connection string that it uses is stored in the My Project folder
under Settings.settings.

My business layer contains objects that consume the data layer to read/
write information...pretty basic. My question is....how do I tell the
data layer to use a different connection string from my web app? I
have a ConnectionStrings group in my ASP.Net web.config that should
always be the one to use...regardless of which database was used to
create the datasets.

How do I accomplish this? Is it simply a matter of making sure the
Name in the Settings.settings file in my DAL is the same as the
connection string in my web.config? In the designer, the type dropdown
says (Connection String) and scope is application. Is 2.0 all set up
so that it will check my application config connection string group
settings first?

Thanks,

Jason
 
D

daokfella

"get it from there to the datasource"

That is the question I want answered. I want to know the best way to
"tell" the DAL to use the new connection string. The DAL contains only
strong-typed datasets created with the dataset designer. Vs.Net 2005
wraps the connection string inside its data set classes.

1. Created a vb class library project.
2. Added dataset items.
3. Dragged tables from server explorer to create dataset items.
4. The auto-generated table adapter classes read the connection string
from the app.config of this project.
5. I want to use this libray in another project and override the
connection string.
6. What's the best way to do this for a data access project created in
this way? When the DAL is reading from the app.config...which
app.config is it reading from? When referencing this in a web app,
where does the DAL get it's setting from? It's app.config is not
referenced in any way.

Maybe I don't quite understand app.config files when they exist in vb
class library projects. What happens when a class library containing
an app.config is referenced by a web project with copy local? I was
thinking that the app settings had to also exist in the web.config.
But it doesn't seem to be working that way.
 

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,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top