L
LINZONGM
Unregistered / Unconfirmed
GUEST, unregistred user!
我用一张表(用PARADOX)做基础,共有5个字段,APPLYUPDATES后在用QUERY的INSERT插入另外两张表
(都有9个字段),在我插入第一张表时就说出错,程序如下:
procedure TJhLRForm.FormShow(Sender: TObject);
begin
With Query1 do
begin
close;
Sql.Clear;
Sql.Add('Delete From JH');
ExecSql;
end;
With DM.Query1 do
begin
Close;
Sql.Clear;
Sql.Add('Select Jh_No,Rq,Sbxh,Dj,Sl,Zje from Jh');
Open;
end;
end;
procedure TJhLRForm.CoolBtn1Click(Sender: TObject);
begin
DM.Query1.ApplyUpdates;
With JHQuery do
begin
Close;
Sql.Clear;
Sql.Add('insert into JH(JH_No,Rq,SBXH,DJ,Sl,ZJE,Jsr,BJ,SM)');
Sql.Add('Values('''+CoolEdit1.Text+''',:Rq,'''+DM.Query1.FieldByName('SBXH').AsString+''','+DM.Query1.FieldByName('DJ').AsString+','+DM.Query1.FieldByName('SL').AsString+','+DM.Query1.FieldByName('ZJE').AsString+','''+CoolEdit3.Text+''',:BJ,''进货'')');
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ParamByName('BJ').AsString:='0';
ExecSql;
end;
With Query1 do
begin
Close;
Sql.Clear;
Sql.Add('insert into JHXX(JH_No,Rq,SBXH,DJ,Sl,ZJE,Jsr,BJ,SM)');
Sql.Add('Values('''+CoolEdit1.Text+''',:Rq,'''+DM.Query1.FieldByName('SBXH').AsString+''','''+DM.Query1.FieldByName('DJ').AsString+''','''+DM.Query1.FieldByName('SL').AsString+''','''+DM.Query1.FieldByName('ZJE').AsString+''','''+CoolEdit3.Text+''','''+DM.Query1.FieldByName('BJ').AsString+''','''+DM.Query1.FieldByName('SM').AsString+''')');
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ExecSql;
end;
With DM.Query do
begin
Close;
Sql.Clear;
Sql.Add('Select * from "SUM.Sql"');
Open;
end;
With DM.JHQuery do
begin
Close;
Sql.Clear;
Sql.Add('Insert Into JHHZ(JH_No,Rq,SL,ZJE,SM)');
Sql.Add('ValuesJH_NO,:Rq,:SL,:ZJE,''进货'')');
ParamByName('JH_No').AsString:=DM.Query.FieldByName('JH_NO').AsString;
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ParamByName('SL').AsInteger:=DM.Query.FieldByName('SL').AsInteger;
ParamByName('ZJE').AsFloat:=DM.Query.FieldByName('ZJE').AsFloat;
ExecSql;
end;
我这样写编译的时候好好的,执行的时候就出错,这是为什么?请大家帮帮小弟!
(都有9个字段),在我插入第一张表时就说出错,程序如下:
procedure TJhLRForm.FormShow(Sender: TObject);
begin
With Query1 do
begin
close;
Sql.Clear;
Sql.Add('Delete From JH');
ExecSql;
end;
With DM.Query1 do
begin
Close;
Sql.Clear;
Sql.Add('Select Jh_No,Rq,Sbxh,Dj,Sl,Zje from Jh');
Open;
end;
end;
procedure TJhLRForm.CoolBtn1Click(Sender: TObject);
begin
DM.Query1.ApplyUpdates;
With JHQuery do
begin
Close;
Sql.Clear;
Sql.Add('insert into JH(JH_No,Rq,SBXH,DJ,Sl,ZJE,Jsr,BJ,SM)');
Sql.Add('Values('''+CoolEdit1.Text+''',:Rq,'''+DM.Query1.FieldByName('SBXH').AsString+''','+DM.Query1.FieldByName('DJ').AsString+','+DM.Query1.FieldByName('SL').AsString+','+DM.Query1.FieldByName('ZJE').AsString+','''+CoolEdit3.Text+''',:BJ,''进货'')');
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ParamByName('BJ').AsString:='0';
ExecSql;
end;
With Query1 do
begin
Close;
Sql.Clear;
Sql.Add('insert into JHXX(JH_No,Rq,SBXH,DJ,Sl,ZJE,Jsr,BJ,SM)');
Sql.Add('Values('''+CoolEdit1.Text+''',:Rq,'''+DM.Query1.FieldByName('SBXH').AsString+''','''+DM.Query1.FieldByName('DJ').AsString+''','''+DM.Query1.FieldByName('SL').AsString+''','''+DM.Query1.FieldByName('ZJE').AsString+''','''+CoolEdit3.Text+''','''+DM.Query1.FieldByName('BJ').AsString+''','''+DM.Query1.FieldByName('SM').AsString+''')');
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ExecSql;
end;
With DM.Query do
begin
Close;
Sql.Clear;
Sql.Add('Select * from "SUM.Sql"');
Open;
end;
With DM.JHQuery do
begin
Close;
Sql.Clear;
Sql.Add('Insert Into JHHZ(JH_No,Rq,SL,ZJE,SM)');
Sql.Add('ValuesJH_NO,:Rq,:SL,:ZJE,''进货'')');
ParamByName('JH_No').AsString:=DM.Query.FieldByName('JH_NO').AsString;
ParamByName('Rq').AsDateTime:=DateTimePicker1.Date;
ParamByName('SL').AsInteger:=DM.Query.FieldByName('SL').AsInteger;
ParamByName('ZJE').AsFloat:=DM.Query.FieldByName('ZJE').AsFloat;
ExecSql;
end;
我这样写编译的时候好好的,执行的时候就出错,这是为什么?请大家帮帮小弟!