Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

DAL should use web.config connectionstring?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eigh - 02 Jul 2007 17:48 GMT
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,
sloan - 03 Jul 2007 14:13 GMT
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).

> I have a 3 tiered archetecture:
>
[quoted text clipped - 12 lines]
>
> Thanks,

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.