Multiple Database

Posts   
 
    
Posts: 3
Joined: 13-Mar-2009
# Posted on: 01-Jan-2011 09:20:54   

Hi,

I am developing a winforms project.

I have a heads database in which I store the list of companies (each company has a database with different name ).

Based on the company selected by the user, I have to connect to the corresponding database.

In this scenario, if a user creates a new company, I have to insert a record in the heads database, create a new database for the company and insert the company details in the company database also.

If any one process fails, I have to rollback all the prior database calls.

Please advise me which model to use, the adapter model or self servicing.

Also guide me in how in can be accomplished in a clean way.

I tried a lot of possible methods with some problem or the other.

Thanks in advance.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Jan-2011 00:01:02   

Hi there,

Are you using Adapter or SelfServicing? What LLBLGen version are you using?

sundaramanikandan wrote:

I have a heads database in which I store the list of companies (each company has a database with different name ).

Based on the company selected by the user, I have to connect to the corresponding database.

Do these databases have the same schema? If so, you can pass a new connection string to each DataAccessAdapter instance.

sundaramanikandan wrote:

If any one process fails, I have to rollback all the prior database calls.

Please elaborate more on this. Is enough to use Transactions?

David Elizondo | LLBLGen Support Team
Posts: 3
Joined: 13-Mar-2009
# Posted on: 03-Jan-2011 06:16:44   

Hi,

I am using llblgen V.3 trial.

I tried using the selfservicing model which did not react as I expected.

Now I am trying using the adapter model.

All my databases have the same schema.

My question is can I use the two adapters at the same time (One to insert in the Heads database and the other to insert in the Company database).

If yes, how am I to use a transaction for each adapter and in case if the second insert fails, how am I to rollback the previous insert.

I have read a lot about llblgen (most of them relate to the self servicing model). Where can a get a complete reference regarding the adapter model?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Jan-2011 09:10:00   

You can pass the connection string in the CTor of the DataAccessAdapter object. So this solves switching the cmpany specific database.

As for Distributed Transactions, please check .NET 2.0+: System.Transactions support

And here is the Adapter documentations: Link

Posts: 3
Joined: 13-Mar-2009
# Posted on: 04-Jan-2011 06:53:40   

Hi,

Thanks.. I will try the same.smile