使用ADO连接ODBC,这样你就不用管数据库是SQL2000还是SQL7了,只要连接到数据库上就行了。

解决方案 »

  1.   

    用SQL Server的自带数据引擎,不通过ODBC
      

  2.   

    不管是7.0还是2000,在ODBC管理器注册时后台引擎都是SQL server,用SQL Server的自带数据引擎引用的是你注册过的新的数据库引擎,所以正如: Drate(小虫) 所说,不用管数据库是SQL2000还是SQL7了,只要连接到数据库上就行了。
    都是微软出的,一样的
      

  3.   

    這樣寫就不用管sql是7.0還是2K了
    procedure TBasDM.DataModuleCreate(Sender: TObject);
    var tempIni: TIniFile;
    tmpServerFrm: TServerFrm;
                    StartForm:TStartForm;
                    i:Integer;
                    tmpList:TStringList;
                    IsAliasName:Boolean;
    begin  IsAliasName:=false;
    tmpList:= TStringList.Create;
    try
       Session.GetAliasNames(tmpList);
      for I := 0 to tmpList.Count - 1 do
          if LowerCase(tmpList[i])='wujindb' then
      IsAliasName:=true;
        if not IsAliasName then
      Session.AddAlias('數據庫別名','MSSQL',WJDataBase.Params);
    finally
       tmpList.Free;
    end;  if WJDataBase.Connected then
        WJDataBase.Connected := False;
      pubLocaOption := [loCaseInsensitive, loPartialKey];
    InitDBbasefile;
      with WJDataBase.Params do
      begin
        Values['SERVER NAME']     := curServerName;
        Values['DATABASE NAME']   := curDBName;
        Values['USER NAME']       := 'sa';
        Values['PASSWORD']        := '';
      end;
      try
          WJDataBase.Open;
      except
    //  if DJShow(CON_CONNECT_FAIL,2) = 6 then
      if Application.MessageBox('數據庫連接失敗,重新設置嗎?','錯誤',
       MB_ICONQUESTION+MB_YESNO)=ID_YES then
        begin
          tmpServerFrm:=TServerFrm.Create(Application);
          tmpServerFrm.ShowModal;
          if tmpServerFrm.ModalResult = mrOk then
     begin
            curServerName := tmpServerFrm.Edit1.Text;
               curDBName := tmpServerFrm.Edit2.Text;
    //           tempIni := TIniFile.Create(GetwinDir + 'Wujin.ini');
               tempIni := TIniFile.Create(ExtractFilePath(Application.ExeName)+'Wujin.ini');
               tempIni.WriteString('SYSTEM', 'SERVER', curServerName);
       tempIni.WriteString('SYSTEM', 'DBNAME', curDBName);
       tmpServerFrm.Free;
       tempIni.Free;
     end;
        end
        else
         begin
          Application.Terminate;
         end;
        end;
        StartForm:=TStartForm.Create(Application);
        StartForm.Show;
        StartForm.Update;
        StartForm.Refresh;
        StartForm.Gauge1.Progress:=0;
        StartForm.Gauge1.MaxValue:=100;
        StartForm.Gauge1.MinValue:=0;
        For i:=1 to 100 Do
          begin
            Sleep(20);
            StartForm.Gauge1.Progress:=StartForm.Gauge1.Progress+1;
          end;
        StartForm.free;
    end
      

  4.   

    可SQL7.0与SQL2000有许多处理上都不一样的,如何同时兼容?
      

  5.   

    要注意的是数据类型的转换。用上Convert来转换比较通用.
      

  6.   

    老兄,放心好了,2K會兼容7.0的,不會有問題的,我的數據庫就是從7.0升級到2K的,用了好幾個月了,也不見有問題。我每天的數據增長大約有2M.