Under what circumstances is an SqlConnection automatically enlisted in an ambient TransactionScope Transaction?

I’ve done some tests since asking this question and found most if not all answers on my own, since no one else replied. Please let me know if I’ve missed anything. Q1: Is connection automatically enlisted in transaction? Yes, unless enlist=false is specified in the connection string. The connection pool finds a usable connection. A … Read more

An unhandled exception of type ‘System.InvalidOperationException’ occurred in System.Data.dll?

You should either use this method: SqlCommand cmd = new SqlCommand(“dbo.workScheduleDataGrid”, sqlcon); or this method SqlCommand cmd = sqlcon.CreateCommand(); to create the command, but not both (the second assignment in your code overwrites the first one). With the second options, you need to specify the command to execute separarely: cmd.CommandText = “dbo.workScheduleDataGrid”; Also, do not … Read more