ts.loadfromfile('初始化数据库.sql'); for i:=0 to ts.Count-1 do begin if ts[i]<>'GO' then ADOQuery1.SQL.Add(ts[i]) else//sqlserver生成的脚本中包含go就运行 begin ADOQuery1.ExecSQL; Label1.Caption:='完成操作:'+inttostr(i)+'行'; update; adoquery1.SQL.Clear; end; end; 看起来笨笨的,别人还有什么好办法吗?
ts.loadfromfile('初始化数据库.sql'); for i:=0 to ts.Count-1 do begin if ts[i]<>'GO' then ADOQuery1.SQL.Add(ts[i]) else//sqlserver生成的脚本中包含go就运行 begin ADOQuery1.ExecSQL; Label1.Caption:='完成操作:'+inttostr(i)+'行'; update; adoquery1.SQL.Clear; end; end; 肯定好用
for i:=0 to ts.Count-1 do
begin
if ts[i]<>'GO' then
ADOQuery1.SQL.Add(ts[i]) else//sqlserver生成的脚本中包含go就运行
begin
ADOQuery1.ExecSQL;
Label1.Caption:='完成操作:'+inttostr(i)+'行';
update;
adoquery1.SQL.Clear;
end;
end;
看起来笨笨的,别人还有什么好办法吗?
var
ts: TStrings;
begin
ts := TStringList.Create;
ts.ts.LoadFromFile('d:\ctable.sql');
ADOQuery.Close;
ADOQuery.SQL.Text := ts.Text;
try
ADOQuery.ExecSQL;
ShowMessage('Yeah!');
except
ShowMessage('fail!');
end;
ts.Free;
end;
for i:=0 to ts.Count-1 do
begin
if ts[i]<>'GO' then
ADOQuery1.SQL.Add(ts[i]) else//sqlserver生成的脚本中包含go就运行
begin
ADOQuery1.ExecSQL;
Label1.Caption:='完成操作:'+inttostr(i)+'行';
update;
adoquery1.SQL.Clear;
end;
end;
肯定好用