DAL should use web.config connectionstring?

G

Guest

I have a 3 tiered archetecture:

Presentation Layer running ASP.NET through VB.NET with a web.config & 2
connection strings defined in the web.config

Business Logic layer which is nothing more than a set of wrappers for the DAL.

Data Access Layer, which is a set of data tables and data adapters created
through the XSD GUI.

I want the Connection Strings from my web.config to appear in the dropdown
list for the properties of the Data Adapters. How can I do this? Right
now, it only includes connection strings from MySettings, (New Connection),
and (None).

Thanks,
 
S

sloan

My mode for doing this is :

I use the EnterpriseLibrary first off.


using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;


namespace MyCompany.Applications.MyCustomApplication.Data
{
public abstract class DataLayerBase
{

private string _instanceName = string.Empty;


public DataLayerBase()
{

}

public DataLayerBase(string instanceName)
{
this._instanceName = instanceName;

}


protected Microsoft.Practices.EnterpriseLibrary.Data.Database
GetDatabase()
{
Database returnDb;
if (this._instanceName.Length > 0)
{
returnDb =
DatabaseFactory.CreateDatabase(this._instanceName);
}
else
{
returnDb = DatabaseFactory.CreateDatabase();
}
return returnDb;
}

}
}



Then all my DataLayer objects (EmployeeData for example) inherit from that
class.

The .config file is just xml, so you can read it using Xpath statements.


which looks like

\\configuration\connectionStrings\add

XmlNodeList nl = root.SelectNodes ( \\configuration\connectionStrings\add) ;

something ~like that ( I have not tested this, just giving you an idea).
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top