473,386 Members | 1,758 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.

How to make an application Database independant

Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella
Nov 19 '05 #1
5 1280
Gustavo:
Check out the Provider Model Design Pattern from:
http://msdn.microsoft.com/library/de...sp02182004.asp

and

http://msdn.microsoft.com/library/de...sp04212004.asp

(parts 1 and 2)

As far as I'm concerned, this is the ultimate way.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Gustavo De la Espriella" <qq@qqq.qq.qq> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella

Nov 19 '05 #2
BG
Maybe I'm not understanding the question, however, how about having multiple
connection strings and using one of them based on what the user selected
from a radiobuttonlist or dropdownlist, etc. ?

"Gustavo De la Espriella" <qq@qqq.qq.qq> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella

Nov 19 '05 #3
Yeah, me too, though I'm not too understand the question here's my opinion.

I don't think it's a good idea to have several kinds of backend running
altogether for an applicaiton. So, I'll assume that you only have one active
backend for the appl.
IMHO, It will depends much on what backend you use for that appl.
i.e: SqlClient is optimized when you use Sql Server for the backend, Oracle
is for Oracle DB and so on.

rgds,
andy
"Gustavo De la Espriella" <qq@qqq.qq.qq> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella

Nov 19 '05 #4
Its for an comercial application that needs to use whatever database the
client prefers a main database, even after the initial installation. I'll
try to understand the Web links from Karl to see if it's what we need.

Thanks,
Gustavo De la Espriella
"Gustavo De la Espriella" <qq@qqq.qq.qq> escribió en el mensaje
news:uG**************@TK2MSFTNGP12.phx.gbl...
Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella

Nov 19 '05 #5
Hello Karl,

While the Provider model is a viable solution for the problem here, I believe
that a better solution might be much simpler by using the AbstractFactory
pattern [1] in conjunction with the DataMapper pattern [2].

For example:

// This class doesnt necessarily need to exist. We could create DataFactory
as an abstract class and define GetDataFactory as a static method on that
class. The choice is yours.
public class DataManager
{
public IDataFactory GetDataFactory()
{
// some code to read the configuration which will determine which
concrete implementation of IDataFactory to return
string dataFactoryType = ConfigurationSettings.AppSettings["dataFactoryType"];
Type type = Type.GetType(dataFactoryType);
return (IDataFactory)Activator.CreateInstance(type); // of course,
you'll probably want to do some caching of this
// since reflection can be expensive. Borrowing a page from the Provider
design pattern implementation, we could cache
// the ConstructorInfo object and invoke it.
// Another option would be to expose this DataManager as a singleton.
}
}

public interface DataFactory
{
IUserMapper GetUserMapper();
}

public interface IUserMapper
{
User Get(string id);
Insert(User user);
Update(User user);
Delete(User user);
}

// Data store provider implementation
class SqlDataFactory : IDataFactory
{
public IUserMapper GetUserMapper()
{
return new SqlUserMapper();
}
}

class SqlUserMapper : IUserMapper
{
// IUserMapper implementation goes here.
}

This is a great pattern to implement, because it easily allows for future
growth. Since all data access is done through the IDataFactory interface
as well as the DataMapper interfaces, the client has no concept of the underlying
data store.

The only things I have to do to add say Oracle support is implement an IDataFactory
that returns the DataMapper classes for the Oracle database.

[1] http://c2.com/cgi/wiki?AbstractFactory
[2] http://www.martinfowler.com/eaaCatalog/dataMapper.html

--
Matt Berther
http://www.mattberther.com
Gustavo:
Check out the Provider Model Design Pattern from:
http://msdn.microsoft.com/library/de...ry/en-us/dnasp
net/html/asp02182004.asp
and

http://msdn.microsoft.com/library/de...ry/en-us/dnasp
net/html/asp04212004.asp

(parts 1 and 2)

As far as I'm concerned, this is the ultimate way.

Karl

"Gustavo De la Espriella" <qq@qqq.qq.qq> wrote in message
news:uG**************@TK2MSFTNGP12.phx.gbl...
Hi,

What's a good way to make an application automatically choose between
SQLClient, ODBC, Oracle and OleDB depending on user's choice?
Thanks,
Gustavo De la Espriella


Nov 19 '05 #6

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

Similar topics

4
by: Douglas | last post by:
Dumb question on the mysql mailing list but what database should I learn, for education and interest? Free and with the possibility of making me more employable would be my only criteria. Douglas
5
by: Gustavo De la Espriella | last post by:
I'm refrasing a question I posted earlier because I didn't explain myself. I need an efficient way to make an especific comercial application able to use whatever database the client prefers a...
4
by: Navin Mishra | last post by:
Hi, Are there any implications of having ASMX and ASPX in same ASP.NET application ? Both would share the same global varriables, etc. Regards Navin
0
by: Mythran | last post by:
I'm not sure how the DAAB for .Net 2.0 works, but the v1.1 DAAB throws SqlException's. Why? When a database raises an error, the DAAB should wrap the error with it's own custom dbms-independant...
5
by: sweet_dreams | last post by:
Hi all, I have such a problem: I would like to create an application in Visual Basic 2005 Express Edition. This application will connect with data base created in MS Access 2003. This...
5
by: DelphiAddict | last post by:
Hi. Has anyone looked into generic factoring for making database independant applications? (Framework 2.0) I have, but I'm in the starting fase. What I do know is that if you only write...
6
by: carsonbj | last post by:
I have an issue where the below operation works on a little-endian architecture but not on a big-endian architecture. I was under the impression that pointer arithmetic is architecture independant...
6
by: Simon Harvey | last post by:
Hi everyone, We have a need to make a Windows Forms (2.0) client application that will be installed on our clients site. The data that the application uses needs to be centrally available to a...
10
by: AA Arens | last post by:
I do have a database with customer info in it. To avoid it will be taken out of our office, is it possible to make it not-readable after a certain period? then every let say seven days, I needs to...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.