试图在Delphi 10.2上将应用程序迁移到FireDAC用法,并且仅使用以下功能: Source on github
procedure TMainForm.ExecuteScript(script: string; memo: TMemo);
var
Log: TStringList;
FN: string;
begin
ShowHourGlassCursor;
ZSQLProcessor.Script.Text := script;
try
ZSQLProcessor.Connection.StartTransaction;
ZSQLProcessor.Execute;
ZSQLProcessor.Connection.Commit;
except
on E:Exception do
begin
ZSQLProcessor.Connection.Rollback;
memo.Text := E.Message;
Exit;
end;
end;
坚持行,但无法相处,任何帮助都将是件好事:
ZSQLProcessor.Script.Text := script;
没有最后一部分的转换函数看起来像这样:
procedure TMainForm.ExecuteScript(script: string; memo: TMemo);
var
Log: TStringList;
FN: string;
begin
ShowHourGlassCursor;
//ZSQLProcessor.Script.Text := script;
try
MyTrinityConnection.StartTransaction;
FDScript1.ValidateAll;
FDScript1.ExecuteAll;
MyTrinityConnection.Commit;
except
on E:Exception do
begin
MyTrinityConnection.Rollback;
memo.Text := E.Message;
Exit;
end;
end;
答案 0 :(得分:0)
要将单个SQL脚本分配给TFDScript对象,您只需将一个Add项TFDSQLScript分配到TFDSQLScripts集合并设置其SQL字符串列表集合输入您选择的SQL命令的文本,例如:
FDScript1.SQLScripts.Add.SQL.Text := script; { ← this adds one TFDSQLScript item to the script collection and to this just added item assigns a SQL script }
当然,这假设TFDSQLScripts集合是明确的,如果之前未调用Clear。