1
我正在使用我正在使用的其中一个Web服务发生这种重复出现的问题。 我正在使用数据适配器使用事务和批量更新。最重要的是,我还使用Oracle Command Builder来获取我分配给dataadapter的插入/删除/更新命令。事务对象与连接对象没有关联 - OracleClient
这里是一些从我的服务中提取的代码;并与错误行:
介意 - 我张贴从我的源代码中提取:
OracleTransaction trx = null;
if ((Transaction.Current.TransactionInformation.DistributedIdentifier == Guid.Empty))
{
con.ConnectionString = con.ConnectionString + ";enlist=false"; ;
con.Open();
trx = con.BeginTransaction();
cmd.Transaction = trx;
}
try
{
dsEmpData.AcceptChanges();
for (int i = 0; i < dsEmpData.Tables[0].Rows.Count; i++)
{
dsEmpData.Tables[0].Rows[i].SetAdded();
}
OracleCommandBuilder cb = new OracleCommandBuilder();
string SQL
= "--MY SELECT COMMAND. REMOVED BECAUSE IT IS NOT NECESSARY IN THIS BLOCK";
OracleDataAdapter da = new OracleDataAdapter(SQL, ConnectionString);
OracleCommandBuilder cmdInsert = new OracleCommandBuilder(da);
dsEmpData.Tables[0].TableName = "TABLENAME".ToUpper();
if ((Transaction.Current.TransactionInformation.DistributedIdentifier == Guid.Empty))
{
da.SelectCommand.Transaction = trx;
da.InsertCommand = cmdInsert.GetInsertCommand();//ERROR LINE
da.InsertCommand.Transaction = trx;
}
da.Update(dsEmpData, "TABLENAME".ToUpper());
if (trx != null)
{ trx.Commit(); }
}
catch (Exception ex)
{
if (trx != null)
{ trx.Rollback(); }
throw new FaultException("MY MESSAGE " + ex.Message);
}
因此,如上面说 - 我得到的异常“交易对象不与连接相关联对象“上述行:da.InsertCommand = cmdInsert.GetInsertCommand();
任何有关此事的帮助将不胜感激。如果您需要更多信息,请让我知道。
在此先感谢。
哇 - 这也许是可能的!让我检查一下,我会回到你身边。 –
Bravo!那就是诀窍。谢谢一堆! 干杯 –
Thx对于这个问题的答案很有帮助,可以帮助我们理解第三方软件存在的问题。 – boutta