473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Database Layer With Different Types Database

I know this is a silly question, but I am looking for the best way.

I build a windows application with standard version and enterprise version.
Standard version use local SQL/Access as database. Enterprise version use
Centralized Web Service as Database. Which is the easiest way to handle this?
I have too many classes have data access.

I can create following classes, How could I use Interface or other ways to
call right DB?
class1
class1_db_sql
class1_db_access
class1_db_webservice
Oct 18 '06 #1
3 1635
Bit weird to use multiple db formats but anyway...

I'd make an interface class then inherit from that and override dependant on
which db.

so say interface was called MyInterface

public class dbAccess : MyInterface //inherit interface

public class dbEnterprise : MyInterface //inherit interface
then when u wanna use the access one:

MyInterface m = new dbAccess();

or the enterprise one

MyInterface m = new dbEnterprise();

And that ofcourse can neatly be used with the factory pattern.

then ur code for your method calls for both enterprise and access versions
will not change.
"Qingdong Z." <Qi*******@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
>I know this is a silly question, but I am looking for the best way.

I build a windows application with standard version and enterprise
version.
Standard version use local SQL/Access as database. Enterprise version use
Centralized Web Service as Database. Which is the easiest way to handle
this?
I have too many classes have data access.

I can create following classes, How could I use Interface or other ways to
call right DB?
class1
class1_db_sql
class1_db_access
class1_db_webservice

Oct 18 '06 #2
Go the the result of this search
http://groups.google.com/groups/sear...ccess+Layer%22

I answered the question more detailed there.


"Qingdong Z." <Qi*******@discussions.microsoft.comwrote in message
news:83**********************************@microsof t.com...
I know this is a silly question, but I am looking for the best way.

I build a windows application with standard version and enterprise
version.
Standard version use local SQL/Access as database. Enterprise version use
Centralized Web Service as Database. Which is the easiest way to handle
this?
I have too many classes have data access.

I can create following classes, How could I use Interface or other ways to
call right DB?
class1
class1_db_sql
class1_db_access
class1_db_webservice

Oct 19 '06 #3
Hi,

It sounds to me like you need a way of easily switching the data layer at compile-time, not runtime. In that case you can extend
Daniel's idea and add conditional compilation to choose the appropriate database at compile-time:

#define ENTERPRISE

using System;

static class DALFactory
{
static IDataAccessLayer Create()
{
#if ENTERPRISE
return new EnterpriseDAL();
#else
return new StandardDAL();
#endif
}
}

If you're using VS.NET then it's even easier. Don't use the #define directive, but instead create a new configuration for your
solution in the Configuration Manager, and define the symbols there. When you want to build for the enterprise select the new
ENTERPRISE configuration that you created from the dropdown (instead of RELEASE or DEBUG). If you want a standard build, just
choose RELEASE.

HTH

--
Dave Sexton

"Qingdong Z." <Qi*******@discussions.microsoft.comwrote in message news:83**********************************@microsof t.com...
>I know this is a silly question, but I am looking for the best way.

I build a windows application with standard version and enterprise version.
Standard version use local SQL/Access as database. Enterprise version use
Centralized Web Service as Database. Which is the easiest way to handle this?
I have too many classes have data access.

I can create following classes, How could I use Interface or other ways to
call right DB?
class1
class1_db_sql
class1_db_access
class1_db_webservice

Oct 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: mountain man | last post by:
Greetings to all database professionals and laymen, Let us make a bold assumption that we have developed a software tool for the SQL Server environment which simply acts as an interface between...
4
by: Luiz Geron | last post by:
Hi all, I'm testing the PDO wrapper to database modules and I'm wondering how few things like this there are around. My problem, actually, is the paramstyle of modules. I want to use kinterbasdb...
27
by: Brett | last post by:
If I want to easily swap the database I'm using, what is the best method for developing that tier in my application? I'll have basically a 4 tier app: 1. presentation 2. business logic 3. data...
3
by: Alan | last post by:
I am coming from other programming tools field, and new to VB .NET. Just wondering what is the common approaching in database programming in VB .NET? 1) Are you guru always using the data aware...
4
by: Martyn Fewtrell | last post by:
Hi there I am just canvassing some opinions so feel free to add yours. I mainly work with VB.Net on dynamic websites driven by Access and have more recently been trying to introduce Business...
4
by: ImOk | last post by:
I need to program generically. I am familiar with the ODBC layer but never used PDO or DB. Does anyone have any experience with these database layers? Thanks
2
by: scott.alfon | last post by:
Hello, i need your help. I want to implement a php-script where I can access to different database types as PostSQL, MySQL etc. Is that possible? Furthermore I want to include an access...
22
by: amygdala | last post by:
Hi, I'm trying to grasp OOP to build an interface using class objects that lets me access database tables easily. You have probably seen this before, or maybe even built it yourself at some...
8
by: morleyc | last post by:
Hi, until recently i was quite happy to add data sources from mssql database in visual studio and drag the datasets directly onto the form this creating a directly editable form which worked well....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.