dac oracle

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Stan.Param,
  FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Vcl.StdCtrls, Vcl.Grids,
  Vcl.DBGrids, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client,
  FireDAC.Phys.OracleDef, FireDAC.VCLUI.Wait, FireDAC.Comp.UI,
  FireDAC.Phys.Oracle;

type
  TForm1 = class(TForm)
    con1: TFDConnection;
    FDQuery1: TFDQuery;
    ds1: TDataSource;
    dbgrd1: TDBGrid;
    btn1: TButton;
    FDPhysOracleDriverLink1: TFDPhysOracleDriverLink;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    btn2: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.btn1Click(Sender: TObject);
begin

   con1.Params.Add('DriverID=Ora');
  con1.Params.Add(
  'Database=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) '
  +'(HOST = my-THINK)(PORT = 1521)))(CONNECT_DATA = (SERVER = DEDICATED)'
  +'(SERVICE_NAME = dcsxxuat)))');
  con1.Params.Add('User_Name=sales_xxdcs');
  con1.Params.Add('Password=sales_xxdcs');
  con1.Params.Add('CharacterSet=UTF8');  //否则中文乱码
  con1.Connected := True;
  FDQuery1.Open('select * from tm_user');

end;


{

DCSUAT =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = my-THINK)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dcsxxuat)
    )
  )

}

procedure TForm1.btn2Click(Sender: TObject);
begin
  with con1.Params do
  begin
    Add('DriverID=Ora');
    Add('Database=127.0.1:1521/dcsxxuat');
    Add('User_Name=sales_xxdcs');
    Add('Password=sales_xxdcs');
    Add('CharacterSet=UTF8'); // 否则中文乱码
  end;
  con1.Connected := True;
  FDQuery1.Open('select * from tm_fix_code');
end;

end.
posted @ 2020-01-09 14:13  创新创造学习整合套路  阅读(246)  评论(0编辑  收藏  举报