.Net opening and closing database connections

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-04-02T00:20:24Z Indexed on 2010/04/02 0:33 UTC
Read the original article Hit count: 350

Filed under:
|
|
|
|

I designed the data access portion of our framework so that every time a business object needs to interact with the database it would have to open a connection, invoke the data access layer (to execute the query), and then close the connection. Then if it needed to run in a transaction it would open the connection, begin the transaction, invoke the data access layer (to execute the query) and then commit the transaction, close the transaction, and finally close the connection.

I did it this way with the mindset of open late and close early... but what if I needed to call other BO's to submit data in a single transaction? Is there a better way to handle opening and closing connections as well as working with transactions?

I'm a rookie in designing application architecture so I hope I'm not doing this wrongly... any help is appreciated.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about architecture