Due to some problems I'm experiencing, I am experimenting with connection pooling in .NET Framework 4. Using SQL Profiler, I can see that every time a connection is fetched from the connection pool, the stored procedure sp_reset_connection is executed.
To get rid of this reset (I don't actually need the sp_reset_connection). I've tried setting the Connection Reset parameter in the connection string to false, but this does not seem to have any effect. I'm thinking that maybe I'm misunderstanding the purpose of the Connection reset parameter.
I have noticed that the Connection reset parameter is not documented at http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx. But it is mentioned on many other places, such as http://www.techrepublic.com/article/educate-yourself-about-net-sql-server-connection-string-syntax/6084879.
If I set the Conection Reset flag to an invalid value (such as 'hello'), I get an exception when opening the connection which indicatest hat the Connection Reset flag is actually used.
Does ADO.NET actually care about the Connection reset flag?
My code below:
static void Main(string[] args)
{
const string connectionString =
"Data Source=(local);Initial Catalog=MyDatabse;User ID=sa;Password=<removed>;Connection Timeout=5;Pooling=true;Min Pool Size=1; Max Pool Size=1; Enlist=false; Connection Reset=false;";
var connections = new List<SqlConnection>();
for (int i = 0; i < 1000000; i++)
{
using (var conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand command = new SqlCommand("SELECT * FROM DatabaseVersion", conn);
command.ExecuteNonQuery();
connections.Add(conn);
}
}
}