以前用ADO写的连接ACCESS数据库,由于记录越来越多,速度慢得不能忍受了,(8万记录,200多M)
  所以只好改用VFP的DBF文件,用BDE通过ODBC连接,将VFP的ODBC驱动也拷到了程序目录,在我的机子上是没有错误了,请高手指点一下,这样连接,在别的系统中,如98,XP等会不会有错误?
//动态设置ODBC数据源unit ODBC;interfaceuses
  Windows,SysUtils, Forms,Registry;procedure ODBCCreate();implementationprocedure ODBCCreate();
var
  RegODBC:Tregistry;
begin
Try
  RegODBC:=Tregistry.Create;
  RegODBC.RootKey:=HKEY_CURRENT_USER;
  RegODBC.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources',true);
  RegODBC.WriteString('MyODBC','Microsoft Visual FoxPro Driver');
  RegODBC.CloseKey;
  if RegODBC.OpenKey('\Software\ODBC\ODBC.INI\MyODBC',True) then
     begin
        RegODBC.WriteString('BackgroundFetch','Yes');
        RegODBC.WriteString('Collate','Machine');
        RegODBC.WriteString('deleted','Yes');
        RegODBC.WriteString('Description','');
        RegODBC.WriteString('Driver',ExtractFilePath(Application.ExeName)+'vfpodbc.dll');
        RegODBC.WriteString('Exclusive','NO');
        RegODBC.WriteString('Null','Yes');
        RegODBC.WriteString('SetNoCountOn','NO');
        RegODBC.WriteString('SourceDB',ExtractFilePath(Application.ExeName));
        RegODBC.WriteString('SourceType','DBF');
     end
  else
    begin
        application.MessageBox('无法创建ODBC数据源,请确认注册表未写保护','警告',mb_ok);
        application.Destroy;
    end;
Finally
  RegODBC.CloseKey;
  RegODBC.free;
end;
end;
end.

解决方案 »

  1.   

    用ADO连DBF文件:
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\temp\;Extended Properties=dbase 5.0;Persist Security Info=False;
      

  2.   

    嗯,我听说ADO连接特别慢不过我先试试
      

  3.   

    连接字符串
    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\temp\;Extended Properties=dbase 5.0;Persist Security Info=False;
      

  4.   

    应该没问题!!!
    Ado你應該參考些, 如 李維的<<delphi 5.x Ado...>>
    的調優方法!本機數據操作, 我感覺, 還是BDE 類的最快!