For a:=StrToInt(Edit3.Text) to StrToInt(Edit4.Text) do
begin
For c:=StrToInt(Edit1.Text) to StrToInt(Edit6.Text) do
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('insert into Tba_kwsz (cs,bm) values (:b,:c)');
parameters.ParamByName('b').Value :=edit6.Text;
parameters.ParamByName('c').Value :=a+c;
adoquery1.ExecSQL;
如果这次插入的数据a+c在数据库中存在就跳过,如果不存在就插入
begin
For c:=StrToInt(Edit1.Text) to StrToInt(Edit6.Text) do
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('insert into Tba_kwsz (cs,bm) values (:b,:c)');
parameters.ParamByName('b').Value :=edit6.Text;
parameters.ParamByName('c').Value :=a+c;
adoquery1.ExecSQL;
如果这次插入的数据a+c在数据库中存在就跳过,如果不存在就插入
begin
with adoquery2 do
begin
close;
sql.Clear;
sql.Add(select * from Tba_kwsz where bm=:c');
parameters.ParamByName('c').Value :=a+c;
open;
end;
if recordCount>0 then continue with adoquery1 do
begin
close;
sql.Clear;
sql.Add('insert into Tba_kwsz (cs,bm) values (:b,:c)');
parameters.ParamByName('b').Value :=edit6.Text;
parameters.ParamByName('c').Value :=a+c;
adoquery1.ExecSQL;
end;
end;
begin
For c:=StrToInt(Edit1.Text) to StrToInt(Edit6.Text) do
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add(select * from Tba_kwsz where bm=:c');
parameters.ParamByName('c').Value :=a+c;
open;
if RecordCount>0 then continue ; close;
sql.Clear;
sql.Add('insert into Tba_kwsz (cs,bm) values (:b,:c)');
parameters.ParamByName('b').Value :=edit6.Text;
parameters.ParamByName('c').Value :=a+c;
adoquery1.ExecSQL;
End;
End;
For a:=StrToInt(Edit3.Text) to StrToInt(Edit4.Text) do
begin
For c:=StrToInt(Edit1.Text) to StrToInt(Edit6.Text) do
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add(select * from Tba_kwsz where bm=:c');
parameters.ParamByName('c').Value :=a+c;
open;
if RecordCount>0 then continue ; close;
sql.Clear;
sql.Add('insert into Tba_kwsz (cs,bm) values (:b,:c)');
parameters.ParamByName('b').Value :=edit6.Text;
parameters.ParamByName('c').Value :=a+c;
adoquery1.ExecSQL;
End;
End;
End;
begin
ADOQUERY1.edit;
ADOQUERY1.fieldbyname('ID').asdtring:=edit1.Text;
ADOQUERY1.fieldbyname('ID2').asdtring:=edit2.Text;
//........
ADOQUERY1.post;
ADOQUERY1.next;
end;