2 Replies - 217 Views - Last Post: 16 March 2012 - 09:03 AM Rate Topic: -----

#1 eakhadar  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-April 10

How to choose connection programatically from oracle/sqlserver/mysql

Posted 16 March 2012 - 08:46 AM

I am developing a program to manage inventory and accounts. different clients need different databases like oracle/sqlserver/mysql etc. i want to make my solution work with all these database servers by only changing one string value .

i want to declare like :

dim mycmd as new myCommand(strServertype)
here if strServertype ="ORACLE" it should return type system.data.oracleclient.oraclecommand
here if strServertype ="MYSQL" it should return type system.data.mysqlclient.mysqlcommand
here if strServertype ="SQL" it should return type System.Data.SqlClient.SqlCommand

Also the connection and dataadaptor object also in the same way.

how can i write a function for this

Is This A Good Question/Topic? 0
  • +

Replies To: How to choose connection programatically from oracle/sqlserver/mysql

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 6460
  • View blog
  • Posts: 23,490
  • Joined: 12-June 08

Re: How to choose connection programatically from oracle/sqlserver/mysql

Posted 16 March 2012 - 08:54 AM

It sounds like you would need to create a custom class that does this work for you. Some sort of encompassing class that takes in a database type.. a connection string.. and outputs a dataset (or how ever you have your data being consumed).

On the internals of this class you would have objects/adapters/connection objects for your various databases.. doing their thing as they normally would and when they are done they have one dataset to return.

Basically blackbox the whole thing.
Was This Post Helpful? 0
  • +
  • -

#3 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 209
  • View blog
  • Posts: 1,369
  • Joined: 16-March 11

Re: How to choose connection programatically from oracle/sqlserver/mysql

Posted 16 March 2012 - 09:03 AM

Personally I always build a separate class for all the database stuff. Any who here's an idea, not necessarily this exact code, cause one it's messy, and two it's bound to cause error. Just the structure of it. :)

Edit: Best to use modi's idea, let's not make habit of ugly practice. :)

This post has been edited by trevster344: 16 March 2012 - 09:05 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1