Best practise/How-To ?

Posts   
 
    
deMarco73
User
Posts: 1
Joined: 28-Apr-2005
# Posted on: 28-Apr-2005 15:29:02   

Hi,

i have created a application with MS-SQL. Now i have ported it to a Access-DB, MySQL,... Is there a way to change the db specific layer at runtime? How should i build up such a application which can access different db's with the same structure? confused

Thanx Marco

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-Apr-2005 16:29:30   

Use adapter.

Then, create a small factory for DataAccessAdapter objects. In your code, you then use IDataAccessAdapter adapter = YourFactory.Create(someDbIDYouInvent); adapter.SaveEntity(..);

etc..

You create for each database a project and you generate code for that. Keep the db structure the same and avoid db specific types like unique_identifier, bit etc.

Of one generated project, you keep the db generic vs.net project and for all databases, you keep the dbspecific projects.

Frans Bouma | Lead developer LLBLGen Pro