Best way to use a DataAccessAdapter object

Posts   
 
    
stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 10-Aug-2007 12:57:31   

Hello,

I have started migrating my winform application from selfservicing to adapter. I'm unsure about the best way to deal with DataAccessAdapter objects.

Which is better ?

1) instantiating a new DataAccessAdapter everytime you need to interact with the database and then closing and disposing it.

2) Creating a DataAccessAdapter once when the application is started, storing it somewhere (for example in a static property), and disposing it when the application is closed.

Knowing that fetches/saves will target the same database 95% of the time.

Any hints would be greatly appreciated. Thanks in advance

Rogelio
User
Posts: 221
Joined: 29-Mar-2005
# Posted on: 10-Aug-2007 13:39:58   

Hi,

I always use the creation of a new DataAccessAdapter model. I prefer this model because it allow to handle any kind of scenario: - one user (each user has a copy of the DataAccess dll assembly). - multiple user (all the users request data to a central DataAccess server, using remoting or web service). - web application.

If you use only one instance of the DataAccessAdapter then you can not handle this scenarios.

stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 10-Aug-2007 22:11:49   

Thanks, In my case it might be a bit different, I don't use adapter because I want a client-server architecture. My application is a typical fat client.

In fact, the reason why I'm now using adapter is that I need the ability to fetch data from a database server, and eventually save to another. It's all just about handling multiple simultaneous database connections.

Any suggestions?

stefcl
User
Posts: 210
Joined: 23-Jun-2007
# Posted on: 11-Aug-2007 11:01:01