Y
yepemig
Unregistered / Unconfirmed
GUEST, unregistred user!
我的前台保存代码是这样的:
procedure TDM.ApplyUpdates(ClientDataSet: TClientDataSet);
var
CustVar: OleVariant;
begin
ClientDataSet.CheckBrowseMode;
if ClientDataSet.ChangeCount > 0 then
CustVar := ClientDataSet.Delta
else
CustVar := null;
DCOMcnn.AppServer.ApplyUpdates(CustVar, ClientDataSet.ProviderName);
if not VarIsNull(CustVar) then
ClientDataSet.Reconcile(CustVar)
else
begin
ClientDataSet.Reconcile(CustVar);
ClientDataSet.Refresh;
end;
end;
我的后台(应用程序服务器)保存代码是这样的:
procedure TBaseServerRDM.ApplyUpdates(var CustVar:OleVariant;
DSPName:OleVariant);
var
ErrCount:Integer;
StrDspName:string;
Cmp:TComponent;
CmpDSP:TDataSetProvider;
begin
StrDspName := string(DSPName);
Cmp := FindComponent(StrDspName);
if (not Assigned(Cmp)) or (not (Cmp is TDataSetProvider)) then
SysUtils.Abort;
CmpDSP := TDataSetProvider(Cmp);
if not ACNN.InTransaction then
ACNN.begin
Trans;
try
if not VarIsNull(CustVar) then
begin
CustVar := CmpDSP.ApplyUpdates(CustVar, 0, ErrCount);
if ErrCount > 0 then
begin
SysUtils.Abort;
end;
end;
ACNN.CommitTrans;
except
ACNN.RollbackTrans;
end;
end;
各控件设置是这样的:
使用DCOMConnection
ADOConnection 连Access
ADOConnection.ISOlationlevel:=ilReadCommitted;
ADOConnection.Mode:=cmReadWrite;
ADODataSet.CacheSize:=1000;
ADODataSet.Connection:=ADOConnection;
ADODataSet.CursorLocation:=clUseServer;
ADODataSet.CursorType:=ctKeyset;
ADODataSet.LockType:=ltBatchOptimistic;
ADODataSet.MarshalOptions:=moMarshalModifiedOnly;
ADODataSet.MaxRecord:=100;
DataSetProvider.DataSet:=ADODataSet;
DataSetProvider.Options.poCascadeDeletes:=True;
DataSetProvider.Options.poCascadeUpdates:=True;
DataSetProvider.Options.poAutoRefresh:=True;
DataSetProvider.Options.poAllowCommandText:=True;
DataSetProvider.UpdateMode:=upWhereChanged;
保存时,我就这样调用上面的保存代码 如M.ApplyUpdates(ClientDataSet1);
如果没有修改数据,直接按保存是正常的,但当修改过数据后,再保存就出问题了...
出现如下错误提示:
Commit 或 Rollback 没有相对应的 begin
Trans.
但我在保存代码中已begin
Trans 了,用SQL作后台数据库时完全正常.
procedure TDM.ApplyUpdates(ClientDataSet: TClientDataSet);
var
CustVar: OleVariant;
begin
ClientDataSet.CheckBrowseMode;
if ClientDataSet.ChangeCount > 0 then
CustVar := ClientDataSet.Delta
else
CustVar := null;
DCOMcnn.AppServer.ApplyUpdates(CustVar, ClientDataSet.ProviderName);
if not VarIsNull(CustVar) then
ClientDataSet.Reconcile(CustVar)
else
begin
ClientDataSet.Reconcile(CustVar);
ClientDataSet.Refresh;
end;
end;
我的后台(应用程序服务器)保存代码是这样的:
procedure TBaseServerRDM.ApplyUpdates(var CustVar:OleVariant;
DSPName:OleVariant);
var
ErrCount:Integer;
StrDspName:string;
Cmp:TComponent;
CmpDSP:TDataSetProvider;
begin
StrDspName := string(DSPName);
Cmp := FindComponent(StrDspName);
if (not Assigned(Cmp)) or (not (Cmp is TDataSetProvider)) then
SysUtils.Abort;
CmpDSP := TDataSetProvider(Cmp);
if not ACNN.InTransaction then
ACNN.begin
Trans;
try
if not VarIsNull(CustVar) then
begin
CustVar := CmpDSP.ApplyUpdates(CustVar, 0, ErrCount);
if ErrCount > 0 then
begin
SysUtils.Abort;
end;
end;
ACNN.CommitTrans;
except
ACNN.RollbackTrans;
end;
end;
各控件设置是这样的:
使用DCOMConnection
ADOConnection 连Access
ADOConnection.ISOlationlevel:=ilReadCommitted;
ADOConnection.Mode:=cmReadWrite;
ADODataSet.CacheSize:=1000;
ADODataSet.Connection:=ADOConnection;
ADODataSet.CursorLocation:=clUseServer;
ADODataSet.CursorType:=ctKeyset;
ADODataSet.LockType:=ltBatchOptimistic;
ADODataSet.MarshalOptions:=moMarshalModifiedOnly;
ADODataSet.MaxRecord:=100;
DataSetProvider.DataSet:=ADODataSet;
DataSetProvider.Options.poCascadeDeletes:=True;
DataSetProvider.Options.poCascadeUpdates:=True;
DataSetProvider.Options.poAutoRefresh:=True;
DataSetProvider.Options.poAllowCommandText:=True;
DataSetProvider.UpdateMode:=upWhereChanged;
保存时,我就这样调用上面的保存代码 如M.ApplyUpdates(ClientDataSet1);
如果没有修改数据,直接按保存是正常的,但当修改过数据后,再保存就出问题了...
出现如下错误提示:
Commit 或 Rollback 没有相对应的 begin
Trans.
但我在保存代码中已begin
Trans 了,用SQL作后台数据库时完全正常.