Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Develop .Net Database-Independant Application

Posted on 2008-10-29
4
Medium Priority
?
408 Views
Last Modified: 2012-08-13
Hello Experts,

I need to change the Data-Layer of a VB.Net Windows Application that uses SQL Server.
Now the requirement is that it can connect to SqlServer, Postgres, or Oracle.
What will be the best way to handle this change?
I am using VB.Net 2.0, so I can't use LinQ. Besides, I use a lot DataSets with TableAdapters, which have the .Net Data Provider objects (SqlClient) hard-coded.

Any ideas on how is the best way to accomplish an application that can connect to multiple database engines?
0
Comment
Question by:jorgesv13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Expert Comment

by:techExtreme
ID: 22838246
Hello,
if you want to connect to multiple database engines, you cannot use sqlclient because that is microsoft specific. You must use oledb stuff.
0
 
LVL 8

Expert Comment

by:rpkhare
ID: 22838489
Take a look at this:
http://www.codeproject.com/KB/database/Multi-Tier.aspx

This will solve your problem.
0
 
LVL 8

Accepted Solution

by:
rpkhare earned 1200 total points
ID: 22838498
0
 
LVL 1

Assisted Solution

by:Abh4IT
Abh4IT earned 800 total points
ID: 22838769
Hi,

As such the idea can be only be developing a DBLayer
So you will have some common DBLayer which provides certain interfaces. Say like
DataAccesFactory, DataAccess. DataAccess Factory provides the implementation for the specific dataaccess based on which DB to use.

Interface IDataAccess methods can be like
OpenConnection(String Connstr)
CloseConnection()
DataSet ExecuteQuery(String sqlQuery) //for select
int ExecuteNonQuery(String sqlEuery) //for insert/update or delete

Now implement this in a class like for example SqlDataAccess, similar <myDB>DataAccess ...Implement these as required by the specific database. Now use DataAccessFactory and load the required DBSupport from configuration or pass an enum. like DataAccessFactory.GetDataAccess(SQLDB) on which you get the IDataAccess object implementing the interface above for that DB.

Also you can explore usage of porvider pattern using
http://www.codeproject.com/KB/database/MpmCodeproject.aspx
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question