公共批量添加方法
function BatchSQL(DC : TADOConnection; Qry : TADOQuery; StrSQL : TStrings): Boolean;
var
i : integer;
begin
Try
DC.BeginTrans;
For i := to StrSQL.Count - do
begin
With Qry do
begin
SQL.Clear;
SQL.Add(StrSQL[i]);
Try
ExecSQL;
Result := True;
except
Result := False;
end;
end;
end;
DC.CommitTrans;
Result := True;
except
DC.RollbackTrans;
Result := False;
end;
end;
var tbSql : TStrings; tbSql := TStringList.Create;
with DMW_Public.DQ_Pub do
begin
while not Eof do
begin
spub_item_content_id:=FieldByName('pub_item_content_id').AsString;
sInsertXConent:=' insert into set_contents(pub_line_id,pub_item_content_id) '
+' values ('''+cbb_lines.KeyItems[cbb_lines.ItemIndex]+''','''+spub_item_content_id+''') ';
tbSql.add(sInsertXConent);
Next;
end;
try
if BatchSQL(DMW_Public.DC_Pub,DMW_Public.DQ_Pub,tbSql) then
begin
ShowErrMsg('配置成功!');
end else
begin
ShowErrMsg('配置失败!');
end;
finally
tbSql.Free;
end;
end;