One VisualStudio project to connect to Oracle, MSSQL and MySQL

Posts   
 
    
afya
User
Posts: 2
Joined: 21-Sep-2009
# Posted on: 21-Sep-2009 18:12:16   

Hello Support, I'm new to LLBLGen (pro v 2.6) and i loved it when i used it for a project where i was using MS SQL 2005 server!smile

This time i need to work on a web application which will be able to connect to either and Oracle db (10g), MSSQL db or a MySQL db. The final product is supposed to provide the user with an option to chose one of these databases. I already know that LLBLGen can generate a project for each of these databases but i not sure whether LLBLGen can be used in such a circumstance where different database technologies are needed in the same application confused Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Sep-2009 04:39:24   

Hi afya,

I assume you have three databases (SQLServer, Oracle and MySql) with equivalent schemas (same tables, fields, relations, etc) and you want to connect to those three indifferently. Yes it is possible.

First of all, you need to use Adapter template set, the life is much easier using Adapter, in this case.

In general, you'd do:

  • **Create **your SQLServer LLBLGen Pro project
  • Use Project Converter (_Customer Area -> v2.6 downloads -> Extras -> Project Converter source code_) to convert SQLServer LLBLGen Pro project to an Oracle LLBLGen Pro project (original is kept, so you create a copy which is converted). Now you have two LLBLGen Pro projects (lgp's): one for SQLServer and one for Oracle
  • Load the Oracle LLBLGen Pro project and check whether there are **type converters **needed because some types in SQLServer aren't available in Oracle.
  • Use the **DDL SQL templates **(_Customer Area -> v2.6 downloads -> Tasks and Templates_) to generate from the Oracle project a create script so you can create the oracle schema (if you don't have the schema already).
  • Generate from both projects code for Adapter. Before generate, please change the connectionString Key name on the Project Properties of each project. So the SQLServer project would be _SQLServer.ConnectionString _and _Oracle.ConnectionString _for Oracle so your app can differentiate them when creating the adapters.
  • **Keep 1 generated DBGeneric **vs.net project (as you've kept them the same it's not important which one) and both DBSpecific projects.
  • Do the same for MySql

Now you have a solution with three DBSpecific projects (SQLServerDBSpecific, OracleDBSpecific and MySqlDBSpecific) and one DBGeneric project.

Then in your code just create the appropiate adapter (YourRootNamespace.Oracle.DatabaseSpecific.DataAccessAdapter, and so on) based on some user selection.

David Elizondo | LLBLGen Support Team
afya
User
Posts: 2
Joined: 21-Sep-2009
# Posted on: 22-Sep-2009 07:33:03   

Hi Daelmo,

Thanks for the info. Yes, I have three databases just as you assumed in your reply. My first encounter with LLBLGen pro was with the SelfServicing template set, which targets a single database type. I guess thats why i found it tricky to deal with such circumstances(though i hope there is a workaround this with SelfServicing anyway because i really love the ease provided the SelfServicing template)

Otherwise, i'll switch to Adapter template set to enjoy the fine databases access control it promises. Thanks

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Sep-2009 11:29:44   

That's a typical case where you should use the Adapter model. SelfServicing is easier to use but with a compromise that it can't be used in such cases.