ADOConn.Connected := False;
LB_Inf.Caption := '正在连接数据库....';
Application.ProcessMessages;
try
//根据ini文件里的连接字符串连接数据库
AppINI := TIniFile.Create(ExtractFilePath(Application.ExeName) +
'AppSys/AppSys.ini');
//解密读入的字符串
ConnStr := AppINI.ReadString('Conn', 'ConnStr', '');
ConnStr := CryptStr(ConnStr);
ADOConn.ConnectionString := ConnStr;
AppINI.Free;
except
AppINI.Free;
Application.MessageBox('未找到配置文件,程序无法启动。', '启动错误', MB_Ok +
Mb_IconInformation);
Close;
end;
try
ADOConn.Connected := True;
except//连接
on E: Exception do
begin
Application.MessageBox(PChar('无法连接数据库,系统返回的错误信息如下:' +
#13 + #13 + E.Message), '连接失败', Mb_OK + Mb_IconInformation);
Close;
end;
end;