Q
Qv15
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个程序,想在程序启动时先建立一个数据库,然后再从一个盘上恢复它原有的内容
我是这样写的,但是程序启动完后就退出了,请问是怎么回事。
Application.Initialize;
S_IniFrm := TS_IniFrm.Create(S_IniFrm);
S_IniFrm.Show;
S_IniFrm.Update;
Application.Title := 'xx管理系统';
Application.CreateForm(TDMFrm, DMFrm);
with DMFrm do
begin
Q_con.Close;
Q_con.SQL.Clear;
Q_con.SQL.Add('SELECT name FROM master.dbo.sysdatabases WHERE name = ''ddxt''');
Q_con.Open;
if Q_con.RecordCount>0 then
begin
ADOConn.Connected:=false;
ADOConn.DefaultDatabase:='ddxt';
ADOConn.Connected:=true;
end
else
try
S_IniFrm.L1.Caption:='正在创建数据库,请稍后...';
Q_con.Close;
Q_con.SQL.Clear;
Q_con.SQL.Add('Create database ddxt');
Q_con.ExecSQL;
Q_Con.Close;
Q_Con.SQL.Clear;
Q_Con.SQL.Add('Restore Database ddxt From disk=' + '''D:/ddxt''');
Q_Con.ExecSQL;
S_IniFrm.L1.Caption:= '数据库创建成功';
ADOConn.Connected:=false;
ADOConn.DefaultDatabase:='ddxt';
ADOConn.Connected:=true;
except
S_IniFrm.L1.Caption:='数据库创建失败,请手动创建';
Exit;
end;
end;
Application.CreateForm(TD_MainFrm, D_MainFrm);
Application.CreateForm(TD_ShudPFrm, D_ShudPFrm);
Application.CreateForm(TS_DdszFrm, S_DdszFrm);
Application.CreateForm(TS_XdszFrm, S_XdszFrm);
Application.CreateForm(TQ_YwjjQFrm, Q_YwjjQFrm);
Application.CreateForm(TD_XiangxFrm, D_XiangxFrm);
Application.CreateForm(TQ_XftjFrm, Q_XftjFrm);
Application.Run;
我是这样写的,但是程序启动完后就退出了,请问是怎么回事。
Application.Initialize;
S_IniFrm := TS_IniFrm.Create(S_IniFrm);
S_IniFrm.Show;
S_IniFrm.Update;
Application.Title := 'xx管理系统';
Application.CreateForm(TDMFrm, DMFrm);
with DMFrm do
begin
Q_con.Close;
Q_con.SQL.Clear;
Q_con.SQL.Add('SELECT name FROM master.dbo.sysdatabases WHERE name = ''ddxt''');
Q_con.Open;
if Q_con.RecordCount>0 then
begin
ADOConn.Connected:=false;
ADOConn.DefaultDatabase:='ddxt';
ADOConn.Connected:=true;
end
else
try
S_IniFrm.L1.Caption:='正在创建数据库,请稍后...';
Q_con.Close;
Q_con.SQL.Clear;
Q_con.SQL.Add('Create database ddxt');
Q_con.ExecSQL;
Q_Con.Close;
Q_Con.SQL.Clear;
Q_Con.SQL.Add('Restore Database ddxt From disk=' + '''D:/ddxt''');
Q_Con.ExecSQL;
S_IniFrm.L1.Caption:= '数据库创建成功';
ADOConn.Connected:=false;
ADOConn.DefaultDatabase:='ddxt';
ADOConn.Connected:=true;
except
S_IniFrm.L1.Caption:='数据库创建失败,请手动创建';
Exit;
end;
end;
Application.CreateForm(TD_MainFrm, D_MainFrm);
Application.CreateForm(TD_ShudPFrm, D_ShudPFrm);
Application.CreateForm(TS_DdszFrm, S_DdszFrm);
Application.CreateForm(TS_XdszFrm, S_XdszFrm);
Application.CreateForm(TQ_YwjjQFrm, Q_YwjjQFrm);
Application.CreateForm(TD_XiangxFrm, D_XiangxFrm);
Application.CreateForm(TQ_XftjFrm, Q_XftjFrm);
Application.Run;