Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

Create a connection object (sql/oledb/odbc) based on connection method/string.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hetal - 26 Apr 2007 18:58 GMT
Hi...

I am a newbie VB.NET developer and i am looking at working with
ADO.NET rather than ADO. In one of our native VB application with ADO,
we used to create 1 connection object and that would help us to
connect to MS-SQL and MySQL alternatively based on the database type
and connection string i provide. So, one connection object was good
enough to connect to any of these 2 type of databases.

The sample connection string we use to connect to the databases are as
follows:

MS-SQL: "Provider=sqloledb;Data Source=<server_name>; Initial
Catalog=<database_name>;User Id=xxx;Password=xxx"

MySQL: "DRIVER={MySQL ODBC 3.51
Driver};SERVER=<server_name>;DATABASE=<database_bame>;UID=xxx;PWD=xxx;OPTION=16427;"

With ADO.NET, it makes us create different connection objects based on
database type and connection string we use. To connect to MS-SQL
database, we will have to create an oleDBConenction object and for
MySQL database, we will have to create an odbcConnection object.

The challenge we face here though is that we had all our database as
MS-SQL and we are moving them to MySQL one by one (some are already
migrated to MySQL). And we would like to make our connect feature such
that it dynamically creates a connection object (any of sql/oledb/
odbc) based on what the back end is and what connection string/method
we are using. Is there a possible way to make it dynamics?

Any help on this one will be very much appreciated. Thanks.
Spam Catcher - 26 Apr 2007 19:42 GMT
Hetal <hetal.a.kapadia@gmail.com> wrote in news:1177610297.674317.326590
@t39g2000prd.googlegroups.com:

> The challenge we face here though is that we had all our database as
> MS-SQL and we are moving them to MySQL one by one (some are already
> migrated to MySQL). And we would like to make our connect feature such
> that it dynamically creates a connection object (any of sql/oledb/
> odbc) based on what the back end is and what connection string/method
> we are using. Is there a possible way to make it dynamics?

You'll need to build a data abstraction layer. The problem with generic
data layers is that different databases support different features so I
believe that's why Microsoft created custom implementations for each
database.

However, there are a couple tools out there to make your ADO.NET "generic":

CoreLab's UNIDirect ADO.NET driver provides access to several database
platforms

Microsoft has the Data Access Application Blocks to may help to connect to
multiple databases.

You can use a DAL framework like LLBLGen Pro/CodeSmith (which contains
layers for several database).

You could build your own custom DAL.

I personally use the LLBLGen Pro DAL framework and it's great :-) Supports
SQL Server, MySQL, DB2, Firebird, Oracle, and more.
Hetal - 30 Apr 2007 17:55 GMT
Thank you Spam Catcher.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.