dmunit.pas

来自「Direct Oracle Access 非常好的Oracle数据库直接访问组」· PAS 代码 · 共 75 行

PAS
75
字号
// Direct Oracle Access - PictureDemo
// Allround Automations
// support@allroundautomations.nl
// http://www.allroundautomations.nl
//
// This application demonstrates:
// - The use of a BLOB field in a dataset
// - The use of Data Definition Language (creating & dropping a table)
// - The use of a Data Module for the DOA components

unit DMUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, OracleData, Oracle;

type
  TDM = class(TDataModule)
    OracleSession: TOracleSession;
    OracleLogon: TOracleLogon;
    OracleDataSet: TOracleDataSet;
    DataSource: TDataSource;
    CheckTableQuery: TOracleQuery;
    CreateTableQuery: TOracleQuery;
    NAME: TStringField;
    INFO: TStringField;
    FILENAME: TStringField;
    PICTURE: TBlobField;
    DropTableQuery: TOracleQuery;
    procedure DMCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DM: TDM;

implementation

{$R *.DFM}

procedure TDM.DMCreate(Sender: TObject);
begin
  // Show the logon dialog
  OracleLogon.Execute;
  // If not connected then exit
  if OracleSession.Connected then
  try
    // Test if the demotable exists
    CheckTableQuery.Execute;
    if CheckTableQuery.Eof then
    begin
      // If not, ask to create it
      if Application.MessageBox('Create demo table DOA_PICTUREDEMO ?', 'Confirm',
           mb_YESNO + mb_IconQuestion) = IDYES then
        CreateTableQuery.Execute
      else
        OracleSession.Connected := False;
    end;
  except
    on E:EOracleError do ShowMessage(E.Message);
  end;
  // If everything is OK activate the dataset
  if OracleSession.Connected then
    OracleDataSet.Active := True
  else
    Application.Terminate;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?