473,513 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data abstraction layer, is there something around?

Hi guys,

I'm coding an application connected to a database. I have some clients that
use this program with 2 or 3 computers, and I use MsSQL Express for them.
But if the client needs more computers to be connected to the database, I
have to use a standard MsSQL. No problem with that, but I want to be able to
switch from a database provider to another in an easy way.

I know that this way to do is called "Data(base) abstraction layer", but I
don't know how to use it. I've read some articles around the Internet, like
this one http://www.codeproject.com/cs/database/dalgen.asp, but I don't want
to have to regenerate source code each time I change the database. If it is
possible, I would like to use SQL to do my queries, and I have to be able to
do "complex" queries (joining, subselecting, ...).

The databases I would like to be able to use are MsSQL (Express or not),
MySQL, and if possible Oracle.

Is there something to do this in the Framework? Or maybe some open source
library?

Thank you for your help.
Oct 13 '06 #1
3 5069
Check out the Data Access Application Block from the Microsoft
Enterprise Library:
http://msdn.microsoft.com/library/en...ssappblock.asp

S. Lorétan wrote:
Hi guys,

I'm coding an application connected to a database. I have some clients that
use this program with 2 or 3 computers, and I use MsSQL Express for them.
But if the client needs more computers to be connected to the database, I
have to use a standard MsSQL. No problem with that, but I want to be ableto
switch from a database provider to another in an easy way.

I know that this way to do is called "Data(base) abstraction layer", but I
don't know how to use it. I've read some articles around the Internet, like
this one http://www.codeproject.com/cs/database/dalgen.asp, but I don't want
to have to regenerate source code each time I change the database. If it is
possible, I would like to use SQL to do my queries, and I have to be ableto
do "complex" queries (joining, subselecting, ...).

The databases I would like to be able to use are MsSQL (Express or not),
MySQL, and if possible Oracle.

Is there something to do this in the Framework? Or maybe some open source
library?

Thank you for your help.
Oct 13 '06 #2

First, its important to understand tiered development.
This will make more simple for you.

Check this:
http://sholliday.spaces.live.com/?_c...26ayear%3d2006

As the previous poster pointed out...............Check into the Enterprise
Library data access application block. (I'll abbreviate this as ELDAB for
this post)

One aspect of the ELDAB is that it allows a "common syntax" to whichever
database you're talking.
Access
Excel
Sql Server
Oracle

And you're able to switch the database.........in a dataConfiguration.config
file (1.1, 2.0 is the same concept but a little different)

............
Back to the tiers:
If you're datalayer object only returns
DataSet's
IDataReader's
Scalars
Void's/Nothing's

The the backend db doesn't become as big an issue.
.........

Now , sometimes the ELDAB is not sufficient.

The next thing you could do is create Interface(s) for the DataAccess Layer.

Lets call one
IEmployeeDataLayerObject
pubic DataSet GetInfo(int empid)
public void UpdateInfo(int empid, string fname, string lname)
You create 2 concrete versions of IEmployeeData
EmployeeDataForAccess : IEmployeeDataLayerObject
and
EmployeeDataForOracle : IEmployeeDataLayerObject

You create a simple Factory class, which returns 1 of the 2 concrete
objects.
See
12/1/2005
Understanding the Simple Factory Pattern
http://sholliday.spaces.live.com/?_c...26ayear%3d2005

and look at the "reflection" example.
Normally, you don't have to go to the extreme of doing this last step.
However, I send alot of xml into my datalayers.

IEmployeeDataLayerObject
public void UpdateInfo(XmlDocument xmlDoc)

In this case, ........... I can actually send the raw xml into Sql
Server.....because it has an OPENXML command.
For Access, there is no internal Xml functionality, so I have .. create a
transaction in code, loop over the xml, and run several statements against
the Access database.
For Oracle, I've played with their xml functionality, and as far as 9.xxxx,
I was disappointed in it.

In this case, the ELDAB is deficient. But I can get around it with the
interfaces for the IEmployeeDataLayerObject, several concrete classes, and
using the "Simple Factory" design pattern with reflection (or "key" method)

This should help.

But first off, you need to get the Tiers correct, or you're just
complicating your life too much.

"S. Lorétan" <tynril@[nospam]gmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi guys,

I'm coding an application connected to a database. I have some clients
that
use this program with 2 or 3 computers, and I use MsSQL Express for them.
But if the client needs more computers to be connected to the database, I
have to use a standard MsSQL. No problem with that, but I want to be able
to
switch from a database provider to another in an easy way.

I know that this way to do is called "Data(base) abstraction layer", but I
don't know how to use it. I've read some articles around the Internet,
like
this one http://www.codeproject.com/cs/database/dalgen.asp, but I don't
want
to have to regenerate source code each time I change the database. If it
is
possible, I would like to use SQL to do my queries, and I have to be able
to
do "complex" queries (joining, subselecting, ...).

The databases I would like to be able to use are MsSQL (Express or not),
MySQL, and if possible Oracle.

Is there something to do this in the Framework? Or maybe some open source
library?

Thank you for your help.


Oct 13 '06 #3
S. Lorétan wrote:
Hi guys,

I'm coding an application connected to a database. I have some
clients that use this program with 2 or 3 computers, and I use MsSQL
Express for them. But if the client needs more computers to be
connected to the database, I have to use a standard MsSQL. No problem
with that, but I want to be able to switch from a database provider
to another in an easy way.

I know that this way to do is called "Data(base) abstraction layer",
but I don't know how to use it. I've read some articles around the
Internet, like this one
http://www.codeproject.com/cs/database/dalgen.asp, but I don't want
to have to regenerate source code each time I change the database. If
it is possible, I would like to use SQL to do my queries, and I have
to be able to do "complex" queries (joining, subselecting, ...).

The databases I would like to be able to use are MsSQL (Express or
not), MySQL, and if possible Oracle.

Is there something to do this in the Framework? Or maybe some open
source library?
If you're looking for a library which allows you to write SQL AND use
all kinds of different databases, you're out of luck: there's no SQL
standard which is implemented by all databases, or you've to fall back
on SQL-92, and even then it's not always implemented in all details in
all db's.

So, you have to make a choice:
- use stored procedures in all the databases you're accessing and call
them using a somewhat unified api. This is maintenance intensive but
could work
- use an O/R mapper. An O/R mapper offers you the ability to work with
multiple databases and not to worry about the different SQL dialects
and db specifics, you just write code against the o/r mapper api and
leave the sql generation over to the o/r mapper.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Oct 14 '06 #4

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

Similar topics

1
3117
by: 11abacus | last post by:
Hi, Just wondering if any of you has thought about or is working on a payment gateway abstraction layer (PEAR-style)? I'm interested on developing that or at least start a discussion about...
16
2990
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
10
5760
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
4
2107
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...
30
2184
by: Luke Wu | last post by:
Hello, >From spending some time in clc, I've come to realize that C's model of the CPU can be totally different from the atual CPU. Is it safe to say that almost nothing can be gleaned about...
5
2118
by: Kevin C | last post by:
I was curious to know what some developers out in the industry are doing when it comes to exposing Data access logic, specifically persistence. This is assuming that your not using an O/R framework...
2
1805
by: Eric Cathell | last post by:
I am using dOOdads as my persistence layer. I have a business object Person that sits in a Project called DOMAIN I have 2 dOOdads in a project called BLL. one is _Person and is declared...
17
46458
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
1
1874
by: BJ Dierkes | last post by:
Hello all, I am looking for opinions on preferred methods of Database Abstraction Layer or Object Relation Mapper (I'm using Python 2.5). I have found a number of options such as those listed...
0
7166
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...
1
7106
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7534
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5689
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5094
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3236
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1601
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
459
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.