procedure TDataModule1.Act_AdoConnectionBeforeConnect(Sender: TObject);
var
Str:string;
begin
if copy(ExtractFilePath(Application.ExeName),2,2)<>':/' then
STR:=copy(ExtractFilePath(Application.ExeName),5,length(ExtractFilePath(Application.ExeName)))+message.mdb;
'
else
STR:=ExtractFilePath(Application.ExeName)+message.mdb;
';
Str:=' Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+STR+
' Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";
'+
' Jet OLEDB
atabase Password="";Jet OLEDB:Engine Type=5;Jet OLEDB
atabase Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;
'+
' Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;
'+
' Jet OLEDB
on''t Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False ';
Act_AdoConnection.ConnectionString:=str;
end;
把上面的代码放到AdoConnection的BeforeConnect事件里,就不会有你说的问题了
需要在uses 下面加入SysUtils和Forms两个单元