Connection Strings

M

michaeltorus

Hi

Trying to sort out how to implement the use of connection strings with our new .Net Data Acces Layer(DAL).

2 solutions have been propoesed. Both suggest storing the connecion string in the machine.config file. The DAL uses SQLCleint namespace. At this stage there is only one SQL data store(with multiple data bases), but that might change in the future. Also, we are not using COM+ / Enterprise services, only manual transactions.

The 2 solutions differ, in that the first requires each part of the application to get the connection string, and pass it through every tier/layer (presentation, business, dalcs) to the DAL ...

The second solution makes it possible for the DAL to retrieve a named datasrouce from machine.config, and only DAL Components(DALCS which inherit the DAL) can specify a datasource.

If this makes any sense, can anyone suggest best of the two options, and why they think that? And if anyone has an even better solution to post that up would be great !

Cheers

Mike
 
M

Miha Markic [MVP C#]

Hi,

michaeltorus said:
Hi

Trying to sort out how to implement the use of connection strings with our
new .Net Data Acces Layer(DAL).

2 solutions have been propoesed. Both suggest storing the connecion string
in the machine.config file. The DAL uses SQLCleint namespace. At this
stage there is only one SQL data store(with multiple data bases), but that
might change in the future. Also, we are not using COM+ / Enterprise
services, only manual transactions.

The 2 solutions differ, in that the first requires each part of the
application to get the connection string, and pass it through every
tier/layer (presentation, business, dalcs) to the DAL ...

The second solution makes it possible for the DAL to retrieve a named
datasrouce from machine.config, and only DAL Components(DALCS which
inherit the DAL) can specify a datasource.

You proabably mean app.config and not machine.config...
If this makes any sense, can anyone suggest best of the two options, and
why they think that? And if anyone has an even better solution to post
that up would be great !

I would go with first solution - so the main application layer has control
on which connection string to use (flexibility - it can control which string
is used).
 
M

michaeltorus

Thanks for your reply... however, both options allow the application layers to specify the connection string.

The differences are as follows:

The first option would require the application layer to read it from machine.config. So every part of the application would need to be able to read from machine.confic, and then pass a connection string, which is essentially a database technology, between application layers and down to the DAL.

The second option only requires that an a DALC (which inherits the DAL, and is still part of the data access layer) is able to name it's datasource. The DAL is then able to read the named datasource from machine.config. Only the DAL needs the ability to read from machine.config, and only the DAL is ever dealing with a real connection string.

Hope that explains it better ....
 

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

Top