全部博文(788)
分类:
2008-10-20 10:36:24
ini:=TRegIniFile.Create; //你做了吗?
你回复之前,我已经找到错误拉。
try
AdoTable1.Active:=true;
except
begin
MessageBox(handle,'数据库连接有问题请与管理员联系!','错误',MB_ok or MB_ICONERROR);
application.Terminate;
end;
end;
在无法连接时候
这个代码为什么不执行application.terminate呢???
gz
var
tempIni: TIniFile;
begin
tempIni :=TIniFile.Create(extractfilepath(ParamStr(0))+'sys.ini');
SQLServerName := tempIni.ReadString('SYSTEM', 'SERVER', '');
SQLDBName := tempIni.ReadString('SYSTEM', 'DBNAME', '');
Password := tempIni.ReadString('SYSTEM', 'Password','');
tempIni.Free;
ConnString :='Provider=SQLOLEDB.1;Password='+password
+';Persist Security Info=True;User ID=sa;Initial Catalog='
+SQLDBName+';Data Source='+SQLServerName;
try
sysdm.DBConnect.connected := false;
sysdm.DBConnect.ConnectionString := ConnString;
sysdm.DBConnect.connected := true;
except
on e:EoleException do
begin
if e.Errorcode = -2147217843 then
begin
MsShow('数据库密码不对!');
end
else if e.Errorcode = -2147467259 then
begin
showmessage('数据库服务器名或数据库名不对!');
application.Terminate;
end;
end;
end;