我在一个窗体里面用到2个datasetbroker,2个datasetbroker指向的是2个不同的数据集,操作的目的是把一个里面选定的值导入到另外的一个数据集里面去。
被选择的数据集的sql语句:SELECT 'false' 选择, ACCENTANCE_NOTIFY_LIST.id, ACCENTANCE_NOTIFY_LIST.kks, ACCENTANCE_NOTIFY_LIST.htbh, ACCENTANCE_NOTIFY_LIST.sbmc, ACCENTANCE_NOTIFY_LIST.xhgg, ACCENTANCE_NOTIFY_LIST.dw, ACCENTANCE_NOTIFY_LIST.rksl, ACCENTANCE_NOTIFY_LIST.dhrq, ACCENTANCE_NOTIFY_LIST.dj, ACCENTANCE_NOTIFY_LIST.je, ACCENTANCE_NOTIFY_LIST.xtmc, ACCENTANCE_NOTIFY_LIST.ghcj, ACCENTANCE_NOTIFY_LIST.ysfs, ACCENTANCE_NOTIFY_LIST.yf, ACCENTANCE_NOTIFY_LIST.cchtz, ACCENTANCE_NOTIFY_LIST.sjbgh, ACCENTANCE_NOTIFY_LIST.qdh, ACCENTANCE_NOTIFY_LIST.ysdh, ACCENTANCE_NOTIFY_LIST.kxzlysdh, ACCENTANCE_NOTIFY_LIST.yccldh, ACCENTANCE_NOTIFY_LIST.dchkm, ACCENTANCE_NOTIFY_LIST.rkrq, ACCENTANCE_NOTIFY_LIST.rkdbh, ACCENTANCE_NOTIFY_LIST.cksl, ACCENTANCE_NOTIFY_LIST.kcsl, ACCENTANCE_NOTIFY_LIST.rkbz, ACCENTANCE_NOTIFY_LIST.jzh, ACCENTANCE_NOTIFY_LIST.xjh, ACCENTANCE_NOTIFY_LIST.bjh, ACCENTANCE_NOTIFY_LIST.bzxs, ACCENTANCE_NOTIFY_LIST.hw, ACCENTANCE_NOTIFY_LIST.wh, ACCENTANCE_NOTIFY_LIST.whdid, ACCENTANCE_NOTIFY_LIST.lybz, ACCENTANCE_NOTIFY_LIST.yssl, ACCENTANCE_NOTIFY_LIST.sssl, ACCENTANCE_NOTIFY_LIST.sbfxid, ACCENTANCE_NOTIFY_LIST.sblb, ACCENTANCE_NOTIFY_LIST.bz, ACCENTANCE_NOTIFY_LIST.th, ACCENTANCE_NOTIFY_LIST.reason
FROM ACCENTANCE_NOTIFY_LIST
WHERE sblb = 221 and rkdbh <> ''
窗体里面的代码:
function TBPBJMX.Select(DataSourceMain, DataSourceSelect: TDataSource; ASelectMode: TSelectMode): Boolean;
var HTB:integer;
begin
DataSourceSelect.DataSet.Close;
DataSourceSelect.DataSet.Open;
with TWINSELECT.Create(Context) do
try
DataGrid2.DataSource := DataSourceSelect;
case ASelectMode of
TSelectMode.smNew:
DataGrid2Column13.Visible := True;
TSelectMode.smModify:
DataGrid2Column13.Visible := False;
end;
HTB:= DataSetBrokertan.DataSet.FieldByName('ContractId').AsInteger;
with TsqlDataSet(DataSetBrokerming.DataSet) do
begin
close;
UserFilter := 'ACCENTANCE_NOTIFY_LIST.kcsl > 0 and ACCENTANCE_NOTIFY_LIST.htbh ='+IntToStr(HTB);
Open;
end;
Result := ShowModal = Business.Forms.Controls.mrOK;
finally
Free;
end;
end;
procedure TBPBJMX.Button6Click(Sender: TObject);
begin
if Select(DataSetBrokerlist, DataSetBrokerming, TSelectMode.smNew) then
begin
//DataSetBrokerming.DataSet.Open;
DataSetBrokerming.DataSet.First;
while not DataSetBrokerming.DataSet.Eof do
begin
if DataSetBrokerming.DataSet.FieldByName('选择').AsString = 'True' then
begin
DataSetBrokerList.DataSet.Append;
DataSetBrokerList.DataSet.FieldByName('sbmc').AsString :=
DataSetBrokerming.DataSet.FieldByName('sbmc').AsString;
DataSetBrokerList.DataSet.FieldByName('xhgg').AsString :=
DataSetBrokerming.DataSet.FieldByName('xhgg').AsString;
DataSetBrokerList.DataSet.FieldByName('sjlysl').AsInteger :=
DataSetBrokerming.DataSet.FieldByName('kcsl').AsInteger;
DataSetBrokerList.DataSet.FieldByName('lydh').AsInteger:=DataSetBrokertan.DataSet.FieldByName('id').AsInteger;
DataSetBrokerList.DataSet.FieldByName('th').AsString :=
DataSetBrokerming.DataSet.FieldByName('th').AsString;
DataSetBrokerList.DataSet.FieldByName('sbid').AsInteger :=
DataSetBrokerming.DataSet.FieldByName('id').AsInteger;
DataSetBrokerList.DataSet.FieldByName('dw').AsInteger :=
DataSetBrokerming.DataSet.FieldByName('dw').AsInteger;
DataSetBrokerList.DataSet.Post;
DataSetBrokerMing.DataSet.Edit;
DataSetBrokerming.DataSet.FieldByName('kcsl').AsInteger:=0;
DataSetBrokerming.DataSet.FieldByName('rkbz').AsInteger:=3;
DataSetBrokerMing.DataSet.Post;
end;
DataSetBrokerming.DataSet.Next;
end;
DataSetBrokerMing.DataSet.ApplyUpdates;
DataSetBrokerList.DataSet.ApplyUpdates;
end;
end;
其实都很简单,我们原来用的平台是Business 3,现在平台升级到X3,原来作的时候没有问题,升级完平台就报错了。
错误是:
---------------------------
X3 Studio
---------------------------
运行备品备件领用单的时候发生异常:invoke batch method error, error occur during invoke ApplyUpdates method, 不允许从数据类型 datetime 到数据类型 int 的隐性转换(表 'tib3_jmis2.dbo.ACCENTANCE_NOTIFY_LIST',列 'kcsl')。请使用 CONVERT 函数来运行此查询。
类型:Exception。
请帮我看一下,谢谢 |