我在使用 SqlTransaction 时遇到问题。这是代码
SqlConnection conn = new SqlConnection(connectionString);
// assume that at this point I add try/catch and the connection is successfully opened.
conn.Open();
SqlTransaction trans = conn.BeginTransaction(IsolationLevel.RepeatableRead);
//.........
// Here I do my action with database, change it, commit, call ExecuteNonQuery, //ExecuteScalar,etc...
// And after that long processing with this transaction, I don't know why trans.Connection //is null. and therefore when I call trans.commit(), an exception was raised?
trans.commit();
有人有任何线索吗?
我认为这可能是因为数据库服务器的内存因连接过多而被占用。但我不确定。
我该如何解决这个问题?