关于ini读取错误问题? Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiDB/html/delphi_20061224190355128.html
Filename:=ExtractFilePath(Paramstr(0))+'SET.INI';
Sid:=ini.ReadString('SETCONFIG','SERVERUSER','sa');
Sname:=ini.ReadString('SETCONFIG','SERVERNAME','yyjys');
SDname:=ini.ReadString('SETCONFIG','SERVERDBNAME','sims');
ini.Free;
会出现一个内存错误对话框?
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;