Supporting multiple database'

T

TClancey

Hi all.

I have an app that needs to connect to either - an Access database, MySql
database or MsSql database. It will be the end users decision which they
want to use.

I've done a lot of work with Access in the past, and a good deal with MySql
and realise that there are syntax issues between these two back ends. I
haven't done a great deal with MsSql yet, but I would imagine that syntax is
going to be an issue here as well.

I really want to avoid writing,
If ConnType = "Access" then DoSql("update ....")
If ConnType = "MySql" then DoSql("update ....")
If ConnType = "MsSql" then DoSql("update ....")
for every single Sql statement in the application, but can't think of an
easy way to parse the commands and check syntax.

Has anyone got any ideas?
Cheers,
Tull.
 
T

Tom Shelton

Hi all.

I have an app that needs to connect to either - an Access database, MySql
database or MsSql database. It will be the end users decision which they
want to use.

I've done a lot of work with Access in the past, and a good deal with MySql
and realise that there are syntax issues between these two back ends. I
haven't done a great deal with MsSql yet, but I would imagine that syntax is
going to be an issue here as well.

I really want to avoid writing,
If ConnType = "Access" then DoSql("update ....")
If ConnType = "MySql" then DoSql("update ....")
If ConnType = "MsSql" then DoSql("update ....")
for every single Sql statement in the application, but can't think of an
easy way to parse the commands and check syntax.

Has anyone got any ideas?
Cheers,
Tull.

You might want to look into an ORM tool, such as nhibernate, wilson or mapper,
llblgen, etc. I am mostly familiar with nhibernate, so I will comment on it -
but it allows you to support multiple databases without having to be overly
worried about the sql syntax of the backend datastore. It supports all of
those options, so it is simply a config file change to move to another db (as
long as you avoid db specific features).

Anyway, you might want to check it out and see if it will work for you.
 
C

Chris Mullins [MVP]

[Connecting to multiple databases]
I really want to avoid writing,
If ConnType = "Access" then DoSql("update ....")
If ConnType = "MySql" then DoSql("update ....")
If ConnType = "MsSql" then DoSql("update ....")

Well, that's really the best option we were able to come up with. We use all
stored procedures, and have ported each sproc to:
SQL Server 2000 / 2005 / MSDE / SQL Exresss (all the same file, at least)
Oracle 10g
MySQL
Postgres

We than have a datalayer (DLL) for each one that wraps the stored
procedures. Using some standard Interface tricks, we can minimize the code,
but it's still time consuming.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top