X
xhliang
Unregistered / Unconfirmed
GUEST, unregistred user!
有一管理系统,通过客户端向服务器端修改多表数据,代码如下,不知何故,一天下来会发生数笔数据出错的情况情况。请各位指教!
procedure TForm16.Button8Click(Sender: TObject);
begin
if (edit12.text = '') or (edit3.text = '')or(edit5.text='')or(edit11.text='') then
begin
showmessage('请填入积分卡号等数据!');
end
else
begin
with adoquery2 do
begin
adoquery2.close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('insert into dm_khjf(dm,xfjf,j_date) values ('''+edit12.text+''','''+edit3.text+''',GetDate())');//将数据插入表
adoquery2.SQL.Add('update dm_kh set xfjf=xfjf+'''+edit3.text+''' where dm='''+edit12.text+'''');//修改表中数据
adoquery2.SQL.Add('insert into dm_khjfb(wzdm,mc,dj2,sl) select dm_khjfa.wzdm,dm_khjfa.mc,dm_khjfa.dj2,dm_khjfa.sl from dm_khjfa');//将数据插入另一表
adoquery2.SQL.Add('update dm_khjfb set j_date=GetDate() where dm is null');//修改另一表数据
adoquery2.SQL.Add('update dm_khjfb set jfz=b.jfz from dm_khjfb a join dm_khjfc b on a.wzdm=b.wzdm');
adoquery2.SQL.Add('update dm_khjfb set xfjf=jfz*sl where dm is null');
adoquery2.SQL.Add('update dm_khjfb set dm='''+edit12.Text+''' where dm is null');
adoquery2.sql.add('update dm_khjfb set j_jine=sl*dj2 where j_jine is null');
adoquery2.sql.add('update dm_khjfb set czdm='''+frmparame.edit3.text+''' where czdm=''''');
adoquery2.sql.add('update dm_khjfb set ckdm='''+edit11.text+''' where ckdm=''''');
adoquery2.ExecSQL;
end;
procedure TForm16.Button8Click(Sender: TObject);
begin
if (edit12.text = '') or (edit3.text = '')or(edit5.text='')or(edit11.text='') then
begin
showmessage('请填入积分卡号等数据!');
end
else
begin
with adoquery2 do
begin
adoquery2.close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('insert into dm_khjf(dm,xfjf,j_date) values ('''+edit12.text+''','''+edit3.text+''',GetDate())');//将数据插入表
adoquery2.SQL.Add('update dm_kh set xfjf=xfjf+'''+edit3.text+''' where dm='''+edit12.text+'''');//修改表中数据
adoquery2.SQL.Add('insert into dm_khjfb(wzdm,mc,dj2,sl) select dm_khjfa.wzdm,dm_khjfa.mc,dm_khjfa.dj2,dm_khjfa.sl from dm_khjfa');//将数据插入另一表
adoquery2.SQL.Add('update dm_khjfb set j_date=GetDate() where dm is null');//修改另一表数据
adoquery2.SQL.Add('update dm_khjfb set jfz=b.jfz from dm_khjfb a join dm_khjfc b on a.wzdm=b.wzdm');
adoquery2.SQL.Add('update dm_khjfb set xfjf=jfz*sl where dm is null');
adoquery2.SQL.Add('update dm_khjfb set dm='''+edit12.Text+''' where dm is null');
adoquery2.sql.add('update dm_khjfb set j_jine=sl*dj2 where j_jine is null');
adoquery2.sql.add('update dm_khjfb set czdm='''+frmparame.edit3.text+''' where czdm=''''');
adoquery2.sql.add('update dm_khjfb set ckdm='''+edit11.text+''' where ckdm=''''');
adoquery2.ExecSQL;
end;