Hi all,
My project is multi-Thread service using SqlConnection (sql server + C#)
, stability and performance are very importance, and there are not too much connection at same time.
In fact, I does has not much experiences of working with TSQL, now I am considering 2 solution of working with SqlConnection:
- Solution1: Using (SqlConnection con = new SqlConnection(someConnectionString)){...} =>
so dispose()
the SqlConnection
each time we use.
- Solution2: Using SortedList<ThreadName, SqlConnection>
to manage SqlConnection
, each Thread using its own 1 SqlConnection
, it was opened 1 time and wasn't dispose()
, so still keep Number of Connection opening at same time is small enough, because we keep Number of Thread at same time is smaller than a threshold.
I have no idea which solution is better (good stability and performance).
Could you give me some guide.
Thank in Advance,
TuanNM