delphi --批量添加
2024-08-25 12:38:42
公共批量添加方法
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;
最新文章
- PHP XML和数组互相转换
- UpdatePanel 中 导出Excel按钮
- hdu 1078 FatMouse and Cheese
- java.util.TreeMap源码分析
- jdk1.8.0_101/bin下各文件解释
- js--小结①
- 纪录一个table元素里面的tr th td
- QT程序启动界面的使用
- onclick=‘’return false“
- Vijos 1011 清帝之惑之顺治 记忆录式的动态规划(记忆化搜索)
- 50. leetcode 520. Detect Capital
- VPS搭建离线下载服务器——后网盘时代
- PS 滤镜——平面坐标变换到极坐标
- 【window】window10永久关闭更新
- 辽宁移动宽带体验及魔百盒M101s-2刷机
- 免费CDN公共库——网站提速 静态资源库
- mysql root情况
- Python学习-41.Python中的断言
- 【poj2411】 Mondriaan's Dream
- SVN代理设置