This SqlTransaction has completed; it is no longer usable.C# 报出的错误,不解,望指教
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 03:15:25
This SqlTransaction has completed; it is no longer usable.C# 报出的错误,不解,望指教
This SqlTransaction has completed; it is no longer usable.C# 报出的错误,不解,望指教
This SqlTransaction has completed; it is no longer usable.C# 报出的错误,不解,望指教
This Transaction has completed; it is no longer usable根源分析
1 链接对象没有打开Transaction
如:XXXTransaction transaction=conn.BeginXXXTransaction();
2 在Command对象中未设置Transaction
可以在new XXXCommand(sqlStr,conn,transaction),也可以用XXXCommand对象的引用打开
com.XXXTransaction=transaction;
3 获取在本conn连接中参入了其他conn
例如:
OleDbConnection conn = DBUtilFactory.getConnection("Access");
updateStr = sb.ToString();
updateStr = updateStr.Substring(0,updateStr.LastIndexOf(",")) + " where id=" + id;
OleDbCommand com = new OleDbCommand(updateStr,conn,ts);
com.ExecuteNonQuery();
ts.Commit();
DataTable table = accessOper.sendData(conn,tableName,id);
dt.Merge(table,false,MissingSchemaAction.Ignore);
count++;
在调用accessOper.sendData()时,两次数据库操作的conn(链接对象)是同一个.
it is no longer usable 错了。
此SQL交易已经完成,它已不再可用