Tuesday, April 05, 2005
Multi-Threaded SqlServer and .NET Database Connections
Using MS SqlServer and .NET in a Muti-User or Multi-threaded environment doesn't behave well when using one Database connection object for all your queries. After the last couple days of database nightmares I've found it's always safer to just instantiate a new db connection object each time you want to perform an ExecuteQuery, ExectueScalar or ExecuteNonQuery. The object of only having one database connection is to reduce the overhead of multiple connections and increase performance, and maybe there is a way to keep a persistant connection to the db that manages concurrent inserts/updates/delets/selects, but in the sake of time and easy of programming just open another connection! Also remember to close all your connections after you use them.
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment