我的程序开始运行时要连接数据库
program Manager;
uses
....
{$R *.res}
procedure AutoRun;
var
RegF : TRegistry;
begin
RegF:=TRegistry.Create;
try
RegF.RootKey:=HKEY_LOCAL_MACHINE;
if RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True) then
RegF.WriteString('WYJ2000Manager','D:\Manager.exe');
finally
RegF.CloseKey;
RegF.Free;
end;
end;begin
Application.Initialize;
AutoRun;
SplashForm := TSplashForm.Create(Application);
SplashForm.Show;
SplashForm.Update;
Sleep(1000);
ConDB := False;
Application.CreateForm(TMainForm, MainForm);
SplashForm.Hide;
SplashForm.Free;
if not ConDB then //现在要连接另一台机器上的ORACLE数据库
Application.Run
else
MainForm.Free;
end.
procedure TMainForm.FormCreate(Sender: TObject);
...
begin
...
try
ADOConnection1.Open;
except
on Exception do
begin //连接出错
MessageDlg('错误005' + #13 + '连接数据库失败!请检查数据库设置!',
mtError, [mbOk], 0);
ConDB := True; //窗口卸载
Exit;
end;
end;
end;这段程序在开机后手动运行正常,但是在开机时自动运行时提示
“连接数据库失败!请检查数据库设置”我自己认为可能是因为 :机器启动是要对网络进行初始设置,而当我的程序运行是网络设置还没完成所以连接数据库不能成功。因为在启动时托盘位置还没有出现本地连接图标我的程序就已经运行了。
不知道自己的分析对不对。请各位高手多多指教如何解决这个问题。
program Manager;
uses
....
{$R *.res}
procedure AutoRun;
var
RegF : TRegistry;
begin
RegF:=TRegistry.Create;
try
RegF.RootKey:=HKEY_LOCAL_MACHINE;
if RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True) then
RegF.WriteString('WYJ2000Manager','D:\Manager.exe');
finally
RegF.CloseKey;
RegF.Free;
end;
end;begin
Application.Initialize;
AutoRun;
SplashForm := TSplashForm.Create(Application);
SplashForm.Show;
SplashForm.Update;
Sleep(1000);
ConDB := False;
Application.CreateForm(TMainForm, MainForm);
SplashForm.Hide;
SplashForm.Free;
if not ConDB then //现在要连接另一台机器上的ORACLE数据库
Application.Run
else
MainForm.Free;
end.
procedure TMainForm.FormCreate(Sender: TObject);
...
begin
...
try
ADOConnection1.Open;
except
on Exception do
begin //连接出错
MessageDlg('错误005' + #13 + '连接数据库失败!请检查数据库设置!',
mtError, [mbOk], 0);
ConDB := True; //窗口卸载
Exit;
end;
end;
end;这段程序在开机后手动运行正常,但是在开机时自动运行时提示
“连接数据库失败!请检查数据库设置”我自己认为可能是因为 :机器启动是要对网络进行初始设置,而当我的程序运行是网络设置还没完成所以连接数据库不能成功。因为在启动时托盘位置还没有出现本地连接图标我的程序就已经运行了。
不知道自己的分析对不对。请各位高手多多指教如何解决这个问题。
解决方案 »
- 重叠I/O 中 waitCommEvent()
- 爆强 delphi 愛好者 [b]c/s或三层 开发模式[/b]
- 设置多显示器分辨率???
- 如何根据汉字得到相应的拼音,(在线等待中…………)
- 滚动控件绘图刷新问题
- 请教大家一个多线程发送email的问题,谢谢了
- 数据的插入。
- 怎样用Delphi编程来实现将aux、com等特殊目录改名为其他名称呢?
- 大分请问Delphi用什么工具控制源代码的版本比较好?
- 怎样才能把网页上的文字拖到我的窗口并显示在窗口上面的richedit上??
- 发现连接远程SQL时windows默认是用命名管道,而不用TCP,导致连接不成功,如何修改为默认tcp/ip连接呢
- 在Delphi中,SizeOf(array)是如何实现的?
i:integer;
begin
while (i<5) or not (AdoConnection1.Active) do //设计数器,可以自己定i的值
begin
try
Adoconnection1.Open;
except
end;
Sleep(1000);
end;
//提示连接失败
end;