-2

We are developing a asp.net web based application, so for example if I want to deploy the same web application with MS access as back end or Sql as back end, the data access layer it should use should be configurable.

If I go with the below architecture

Model

Employee
    ID
    Name

DAL

EmployeeAccessDb (Uses inline queries)
    GetAll
    GetByID
    Insert
    Update
    Delete

EmployeeSqlDb (Uses stored procedures)
    GetAll
    GetByID
    Insert
    Update
    Delete

Page (Uses EmployeeAccessDb / EmployeeSqlDb)

ObjectDataSource SelectMethod="GetAll" TypeName=" < EmployeeAccessDb / EmployeeSqlDb >"
Insert
Update
Delete

So if I use Access as back end the page should use Access DAL and if I use Sql page should use SQL DAL.

Please let me know how can I make this configurable.

Arun
  • 42
  • 1
  • 8

1 Answers1

1

please you web.config for configuration and in your DAL read the value form the web.config and make the nessesary call to the database

You'll need to add a reference to System.Configuration. You should be using the ConfigurationManager

    String Activedatabase = ConfigurationManager.AppSettings["ActiveDatabase"];

web.config will look like this

    <appSettings>
     <add key="ActiveDatabase" value="SQLDB"/>
    </appSettings>
Shafqat Masood
  • 2,532
  • 1
  • 17
  • 23