.Net opening and clossing 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:23 UTC
Read the original article Hit count: 492

Filed under:

I currently designed the data access portion of our framework so that every time a business object needed 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 at architecting applications so I hope I'm not doing this wrong...any help is appreciated.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about architecture