TSession控件主要的用途?如何使用?

解决方案 »

  1.   

    看帮助::DescriptionUse TSession to manage a group of database connections within an application. There are three uses for TSession: standard, multiple net files for Paradox, and multi-threaded database applications.Delphi automatically creates a globally accessible default TSession component named Session for all database applications. The default session component handles standard database connections. An application can control the default session by accessing its properties, events, and methods at runtime.Database applications that must simultaneously access Paradox tables located in different network locations can establish multiple sessions, one for each network location.Finally, database applications that must establish multiple, concurrent connections to the same database, such as performing two queries against the same data at once, are multi-threaded applications. Multi-threaded applications must create and maintain one additional session component for each simultaneous connection to a single database server.Note: Applications that maintain multiple sessions can manage them through the TSessionList component. A default session list component, called Sessions梟ote the plural which distinguishes it from the default session component, Session梚s automatically created for all database applications.
    Note: TSession implements the IDBSession interface, which allows the global PasswordDialog function to supply passwords to the component.
      

  2.   

    可以用来动态修改BDE;
    procedure TfrmMain.SetSession;
    var
      MyList: TStringList;
      sDir : String;
      cFileIni : String;
      ClientIni :TIniFile;
      str : String;
    begin
      sDir := ExtractFilePath(Application.ExeName);
      cFileIni := sDir+'SystemSetup.ini';
      Session1.Active := False;
      MyList := TStringList.Create;
      ClientIni := TIniFile.Create(cFileIni);  //调用的文件名
      str := ClientIni.ReadString('FileServer','host',''); //取得字符
      try
        with MyList do
        begin
          Add('SERVER NAME='+str);
          Add('HOST NAME='+str);
          Add('BLOB SIZE=1024');
          Add('BLOBS TO CACHE=1024');
          Add('USER NAME=tygdsys');
        end;
        if not Session.IsAlias('TLGDBDE') then
          Session1.AddAlias('TLGDBDE', 'mssql', MyList)
        else
          Session1.ModifyAlias('TLGDBDE',MyList);
        Session1.SaveConfigFile;
        Session1.Active := True;
      finally
        MyList.Free;
      end;
    end;
      

  3.   

    Borland已经停止开发BDE, 和他相关的控件, 如Tsession, 也会渐渐退出舞台. 无论是用於Linux的Kylix或.net的 Delphi.net都不会有任何相关BDE的工具. 因此我以为多花时间於Tclientdataset, DataSnap, DbExpress和Tdataset相关的控件较好.  学BDE, 只要学用用最基本的, 如Ttable, Tquery等便可以了.