unidac使用演示

unit Unit1;



interface



uses

   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

   Dialogs, StdCtrls, Grids, DBGrids, DB, DBAccess, Uni, MemDS, UniProvider,

   InterBaseUniProvider;



type

   TForm1 = class(TForm)

     UniConnTest: TUniConnection;//用于数据库的连接

     InterBaseUniProTest: TInterBaseUniProvider;//ib/FB的数据提供

     UniQryTest: TUniQuery;

     UniDataSrTest: TUniDataSource;

     DBGrid1: TDBGrid;

     Button1: TButton;

     Button2: TButton;

    procedure Button1Click(Sender: TObject);

    procedure Button2Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;



var

   Form1: TForm1;



implementation



{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);

begin

  with UniConnTest do

  begin

     ProviderName := 'interbase';//这里确定为interbase 但是可以支持firebird

     Password := 'masterkey';//数据库密码

     Username := 'sysdba';//数据库密码

     Server := '';

     Database := 'TD_HOUSE.FDB';//数据库文件的位置,这里在当前目录

     SpecificOptions.Clear;

     SpecificOptions.Add('InterBase.ClientLibrary=fbembed.dll');//设置embeddll驱动位置

     SpecificOptions.Add('InterBase.CharLength=0');//设置为0让,unidac自动读取fb设置

     SpecificOptions.Add('SQLDialet=3');//设置为3

     SpecificOptions.Add('USEUnicode=true');//迟滞unicode 有人说有问题 我没有发现

    try

       Connect;

       ShowMessage('OK');

    except

       ShowMessage('eer');

    end;

  end;

end;



procedure TForm1.Button2Click(Sender: TObject);

begin

   UniQryTest.Close;

   UniQryTest.SQL.Text := 'select * from TB_SYS_LOG';

// UniQryTest.FetchingAll;

   UniQryTest.DisableControls;

   UniQryTest.Open;

   UniQryTest.EnableControls;

end;



end.

 

你可能感兴趣的:(id)