其实看看注册表信息,你就可以通过ODBC直接写一个DSN
然后用BDE连接
regKey := TRegistry.Create;
try
regKey.RootKey := HKEY_LOCAL_MACHINE;
regKey.OpenKey('/Software/ODBC/ODBC.INI/aaaaaaaaaa',true);
regKey.WriteString('DBQ', strDir + localDBName);
GetMem(strSysDir, 255);
GetSystemDirectory(strSysDir, 255);
regKey.WriteString('Driver', strSysDir + '/odbcjt32.dll');
regKey.WriteInteger('DriverId',25);
regKey.WriteString('FIL','MS Access;');
regKey.WriteInteger('SafeTransactions',0);
regKey.WriteString('UID','');
regKey.OpenKey('/Software/ODBC/ODBC.INI/aaaaaaaaaa/Engines',true);
regKey.OpenKey('/Software/ODBC/ODBC.INI/aaaaaaaaaa/Engines/Jet',true);
regKey.WriteString('ImplicitCommitSync','');
regKey.WriteInteger('MaxBufferSize',2048);
regKey.WriteInteger('PageTimeout',5);
regKey.WriteInteger('Threads',3);
regKey.WriteString('UserCommitSync','Yes');
regKey.OpenKey('/Software/ODBC/ODBC.INI/ODBC Data Sources',True);
regKey.WriteString('aaaaaaaaaa','Microsoft Access Driver (*.mdb)');
except
MessageDlg('创建DSN失败', mtError, [mbOK], 0);
PostQuitMessage(-1);
Exit;
end;
regKey.Free;
对于密码提示问题,你可以将数据库连接控件的LoginPrompt属性设为False
这样在程序中就不会有密码提示了