您的位置:首页 > 其它

关于ini读取错误问题?

2008-10-20 10:29 148 查看
关于ini读取错误问题? Delphi / Windows SDK/API
http://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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: