ado连access数据库,access数据库放于光盘上,如果在win2000系统下,一切正常,
但是把程序放到win98下,ado就没法连接光盘上的access数据库了,因为光盘上的的文件都是只读属性的,ado在98下竟然要求数据库不能只读,才可以连。请问有什么方法可解决在98下用ado连光盘上的access数据库?

解决方案 »

  1.   

    你把ado的操作方式设置为只读(拒绝写)可以吗?
      

  2.   

    通过ODBC访问
        try
        RegisterTemp:=TRegistry.Create;
        With RegisterTemp do
        begin
            RootKey:=HKEY_LOCAL_MACHINE;
            if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Source',True) then
                WriteString('yourAppName','Microsoft Access Driver (*.mdb)');
            CloseKey;
            if OpenKey('Software\ODBC\ODBC.INI\yourAppName',True) then
               begin
                   WriteString('DBQ',YourPath+Access.MDB');
                   WriteString('Driver','C:\windows\System32\odbcjt32.dll');
                   WriteInteger('DriverId',25);
                   WriteString('FIL','Ms Access;');
                   WriteInteger('SafeTranction',0);
                   WriteString('UID','');
                   bData[0]:=0;
                   WriteBinaryData('Exclusive',bData,1);
                   WriteBinaryData('ReadOnly',bData,1);
                   WriteString('PWD','yourpassword');
               end;
            CloseKey;
            if OpenKey('Software\ODBC\ODBC.INI\yourAppName\Engines\Jet',True) then
               begin
                   WriteString('ImplicitCommitSync','');
                   WriteInteger('MaxBufferSize',2048);
                   WriteInteger('PageTimeout',5);
                   WriteInteger('Threads',3);
                   WriteString('UserCommitSync','Yes');
               end;
        end;
        except
           MessageBox(Handle,'创建数据源失败!',pchar('yourAppName'),MB_OK+MB_ICONINFORMATION);
           Application.Terminate;
        end;
        try
        ADOConnection1.ConnectionString:='Provider=MSDASQL.1;Persist Security Info=False;Data Source=yourAppName';
        ADOConnection1.LoginPrompt:=False;
        ADOConnection1.Connected:=True;
        except
            MessageBox(Handle,'数据库连接失败!!',pchar('yourAppName'),MB_OK+MB_ICONINFORMATION);
            Application.Terminate;
        end;
      

  3.   

    access文件访问时一般会产生一个记录锁订文件.ldb,由于光盘不可写...
      

  4.   

    缺少一些系统文件, 你安装office2000到你的98下试试。
      

  5.   

    但是为什么在win2000操作系统下就可以呢?