473,790 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1295
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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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 = ConfigurationSe ttings.AppSetti ngs["dataFactoryTyp e"];
Type type = Type.GetType(da taFactoryType);
return (IDataFactory)A ctivator.Create Instance(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******** ******@TK2MSFTN GP12.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
2117
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
1321
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 main database, even after the initial installation. It's a Balanced Scorecard System. And though the structure remains the same, the client should be able to choose its database (MySQL, SQLServer, Acces, etc). Thanks,
4
1570
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
826
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 exception. By throwing the dbms-dependant exceptions (SqlException), you still have to catch those exceptions in code and determine what to do from there, relying on the project(s) calling the DAAB to still be dbms dependant. Should there be a...
5
1094
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 application will do some operations on tables in database: select, insert, update, delete. And my question is: What can I do to make this application independently work on other computers?? Saying independently work I mean that there will be no
5
1627
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 code, you are able to make fairly database independant applications with not much more effort that
6
3664
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 and bitwise operations are architecture dependant. The intention is to store two bytes, as chars, extracted from a short input parameter as: <code> void foo(short id_pair) { char *ptr = &id_pair;
6
2009
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 potentially large number of other sites, which would seem to leave us with our traditional approach, or having a central database server on a dedicated server someplace.
10
2446
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 "extend the license", so it will last another week. It consists of queries, forms, and tables, format Access 2003. Bart
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10413
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.