Originally posted by woohoo
View Post
The black art of databases.
The black art of databases.
conn.StateChange += new StateChangeEventHandler(OnStateChange); conn.Open();
private static void OnStateChange(object sender, StateChangeEventArgs args)
{
if (args.OriginalState == ConnectionState.Closed
&& args.CurrentState == ConnectionState.Open)
{
using (SqlCommand cmd = ((SqlConnection)sender).CreateCommand())
{
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SET ARITHABORT OFF;";
cmd.ExecuteNonQuery();
}
}
}

Leave a comment: