L
ltqlyy125
Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
我写了个INI文件来读入数据库的路径以达到动态连接数据库的作用但读数据库时提示“access violation at address 004ff65655 in module 'project2.ext',read of address 0000033432”请问该怎么办?
::......
我写的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
var
filename,path:string;
inifile:Tinifile;
begin
filename:=ExtractFilePath(application.ExeName)+'path.ini';
inifile:=tinifile.create(filename);
try
if fileexists(filename) then
begin
path:=inifile.ReadString('path','datapath','');
datamodule3.ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+path;
datamodule3.ADOConnection1.LoginPrompt:=false;
datamodule3.ADOConnection1.Connected:=true;
inifile.Free;
end
else
begin
Application.MessageBox('数据库联接出错!', '错误', MB_OK + MB_ICONERROR);
Application.Terminate;
end;
except
begin
Application.MessageBox('数据库联接出错!', '错误', MB_OK + MB_ICONERROR);
Application.Terminate;
end;
end;
end;
编译到datamodule3.ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+path;时就出错。