在李维的《Delphi5.X ADO/MTS/COM+高级程序设计篇 》p444提到了这个问题,他的解决办法是修改provider程序单元中的TDataSetProvider.InternalApplyUpdates方法,以下是他修改的代码:
function TDataSetProvider.InternalApplyUpdates(const Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer): OleVariant;
var
TransactionStarted: Boolean;
begin
CheckDataSet;
TransactionStarted := not IProviderSupport(DataSet).PSInTransaction;
//!!! Modify By Gordion Li
if ( (TransactionStarted) and (GetObjectContext = nil) ) then
IProviderSupport(DataSet).PSStartTransaction;
try
CheckResolver;
Resolver.FUpdateTree.InitData(DataSet);
try
Result := inherited InternalApplyUpdates(Delta, MaxErrors, ErrorCount);
finally
Resolver.FUpdateTree.InitData(nil);
end;
finally
//!!! Modify By Gordion Li
if ( (TransactionStarted) and (GetObjectContext = nil) ) then
IProviderSupport(DataSet).PSEndTransaction((ErrorCount <= MaxErrors) or (MaxErrors = -1));
end;
end;
你可以看一下问题是否依然存在。
function TDataSetProvider.InternalApplyUpdates(const Delta: OleVariant; MaxErrors: Integer;
out ErrorCount: Integer): OleVariant;
var
TransactionStarted: Boolean;
begin
CheckDataSet;
TransactionStarted := not IProviderSupport(DataSet).PSInTransaction;
//!!! Modify By Gordion Li
if ( (TransactionStarted) and (GetObjectContext = nil) ) then
IProviderSupport(DataSet).PSStartTransaction;
try
CheckResolver;
Resolver.FUpdateTree.InitData(DataSet);
try
Result := inherited InternalApplyUpdates(Delta, MaxErrors, ErrorCount);
finally
Resolver.FUpdateTree.InitData(nil);
end;
finally
//!!! Modify By Gordion Li
if ( (TransactionStarted) and (GetObjectContext = nil) ) then
IProviderSupport(DataSet).PSEndTransaction((ErrorCount <= MaxErrors) or (MaxErrors = -1));
end;
end;
你可以看一下问题是否依然存在。
装完UpdatePak后,可以提交而没有错误信息。
但是,如果我的服务器为"支持事务或不支持事务"类型就一切正常。
当服务器设为"需要事务或需要新事务"提交完后,SQL-Server7的数据库并没有被更改。
也就是说,虽然客户程序执行了提交,而没有错误信息,似乎提交成功的时候,一刷新,数据又回去了。
然道一定要用"支持事务或不支持事务"的事务类 型吗?
支持事务的com+三层中客户端有"不能在此会话中打开一个新的事务"怎么解决
有人做过MTS应用吗?帮帮忙吧。