Стартовый пул
This commit is contained in:
127
ZEOSDBO/examples/blobs/ZBlobs.dof
Normal file
127
ZEOSDBO/examples/blobs/ZBlobs.dof
Normal file
@@ -0,0 +1,127 @@
|
||||
[FileVersion]
|
||||
Version=6.0
|
||||
[Compiler]
|
||||
A=8
|
||||
B=0
|
||||
C=1
|
||||
D=1
|
||||
E=0
|
||||
F=0
|
||||
G=1
|
||||
H=1
|
||||
I=1
|
||||
J=0
|
||||
K=0
|
||||
L=1
|
||||
M=0
|
||||
N=1
|
||||
O=1
|
||||
P=1
|
||||
Q=0
|
||||
R=0
|
||||
S=0
|
||||
T=0
|
||||
U=0
|
||||
V=1
|
||||
W=0
|
||||
X=1
|
||||
Y=1
|
||||
Z=1
|
||||
ShowHints=1
|
||||
ShowWarnings=1
|
||||
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
[Linker]
|
||||
MapFile=0
|
||||
OutputObjs=0
|
||||
ConsoleApp=1
|
||||
DebugInfo=0
|
||||
RemoteSymbols=0
|
||||
MinStackSize=16384
|
||||
MaxStackSize=1048576
|
||||
ImageBase=4194304
|
||||
ExeDescription=
|
||||
[Directories]
|
||||
OutputDir=
|
||||
UnitOutputDir=
|
||||
PackageDLLOutputDir=
|
||||
PackageDCPOutputDir=
|
||||
SearchPath=
|
||||
Packages=vcl;rtl;dbrtl;adortl;vcldb;vclx;bdertl;vcldbx;ibxpress;dsnap;cds;bdecds;qrpt;teeui;teedb;tee;dss;teeqr;visualclx;visualdbclx;dsnapcrba;dsnapcon;VclSmp;vclshlctrls;vclie;xmlrtl;inet;inetdbbde;inetdbxpress;inetdb;nmfast;webdsnap;websnap;dbexpress;dbxcds;dclOffice2k
|
||||
Conditionals=
|
||||
DebugSourceDirs=
|
||||
UsePackages=0
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
Launcher=
|
||||
UseLauncher=0
|
||||
DebugCWD=
|
||||
[Language]
|
||||
ActiveLang=
|
||||
ProjectLang=
|
||||
RootDir=
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1033
|
||||
CodePage=1252
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
[HistoryLists\hlDebugSourcePath]
|
||||
Count=3
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=build
|
||||
Item2=compile
|
||||
[HistoryLists\hlUnitAliases]
|
||||
Count=1
|
||||
Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
[HistoryLists\hlSearchPath]
|
||||
Count=7
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=build
|
||||
Item2=../core;../parse
|
||||
Item3=$(DELPHI)\Lib\Debug
|
||||
Item4=../core;../plain
|
||||
Item5=src
|
||||
Item6=src;test
|
||||
[HistoryLists\hlUnitOutputDirectory]
|
||||
Count=4
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=build
|
||||
Item2=../../packages/delphi6/compile
|
||||
Item3=compile
|
||||
[HistoryLists\hlOutputDirectorry]
|
||||
Count=3
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=../../packages/delphi6/compile
|
||||
Item2=compile
|
||||
[HistoryLists\hlBPLOutput]
|
||||
Count=4
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=build
|
||||
Item2=../../packages/delphi6/compile
|
||||
Item3=compile
|
||||
[HistoryLists\hlDCPOutput]
|
||||
Count=4
|
||||
Item0=../../packages/delphi6/build
|
||||
Item1=build
|
||||
Item2=../../packages/delphi6/compile
|
||||
Item3=compile
|
71
ZEOSDBO/examples/blobs/ZBlobs.dpr
Normal file
71
ZEOSDBO/examples/blobs/ZBlobs.dpr
Normal file
@@ -0,0 +1,71 @@
|
||||
{*********************************************************}
|
||||
{ }
|
||||
{ Zeos Database Objects }
|
||||
{ Blobs Example Application }
|
||||
{ }
|
||||
{ Originally written by Sergey Seroukhov }
|
||||
{ }
|
||||
{*********************************************************}
|
||||
|
||||
{@********************************************************}
|
||||
{ Copyright (c) 1999-2006 Zeos Development Group }
|
||||
{ }
|
||||
{ License Agreement: }
|
||||
{ }
|
||||
{ This library is distributed in the hope that it will be }
|
||||
{ useful, but WITHOUT ANY WARRANTY; without even the }
|
||||
{ implied warranty of MERCHANTABILITY or FITNESS FOR }
|
||||
{ A PARTICULAR PURPOSE. See the GNU Lesser General }
|
||||
{ Public License for more details. }
|
||||
{ }
|
||||
{ The source code of the ZEOS Libraries and packages are }
|
||||
{ distributed under the Library GNU General Public }
|
||||
{ License (see the file COPYING / COPYING.ZEOS) }
|
||||
{ with the following modification: }
|
||||
{ As a special exception, the copyright holders of this }
|
||||
{ library give you permission to link this library with }
|
||||
{ independent modules to produce an executable, }
|
||||
{ regardless of the license terms of these independent }
|
||||
{ modules, and to copy and distribute the resulting }
|
||||
{ executable under terms of your choice, provided that }
|
||||
{ you also meet, for each linked independent module, }
|
||||
{ the terms and conditions of the license of that module. }
|
||||
{ An independent module is a module which is not derived }
|
||||
{ from or based on this library. If you modify this }
|
||||
{ library, you may extend this exception to your version }
|
||||
{ of the library, but you are not obligated to do so. }
|
||||
{ If you do not wish to do so, delete this exception }
|
||||
{ statement from your version. }
|
||||
{ }
|
||||
{ }
|
||||
{ The project web site is located on: }
|
||||
{ http://zeos.firmos.at (FORUM) }
|
||||
{ http://zeosbugs.firmos.at (BUGTRACKER) }
|
||||
{ svn://zeos.firmos.at/zeos/trunk (SVN Repository) }
|
||||
{ }
|
||||
{ http://www.sourceforge.net/projects/zeoslib. }
|
||||
{ http://www.zeoslib.sourceforge.net }
|
||||
{ }
|
||||
{ }
|
||||
{ }
|
||||
{ Zeos Development Group. }
|
||||
{********************************************************@}
|
||||
|
||||
program ZBlobs;
|
||||
|
||||
uses
|
||||
{$IFDEF LINUX}
|
||||
QForms,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
{$ENDIF}
|
||||
ZBlobsMain in 'ZBlobsMain.pas' {frmMain};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TfrmMain, frmMain);
|
||||
Application.Run;
|
||||
end.
|
||||
|
337
ZEOSDBO/examples/blobs/ZBlobsMain.dfm
Normal file
337
ZEOSDBO/examples/blobs/ZBlobsMain.dfm
Normal file
@@ -0,0 +1,337 @@
|
||||
object frmMain: TfrmMain
|
||||
Left = 195
|
||||
Top = 110
|
||||
Width = 738
|
||||
Height = 643
|
||||
HorzScrollBar.Range = 202
|
||||
ActiveControl = cbxProtocol
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'ZeosDBO Blobs Test'
|
||||
Color = clBackground
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
Font.Style = []
|
||||
OldCreateOrder = True
|
||||
OnCreate = FormCreate
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object pnControl: TPanel
|
||||
Left = 530
|
||||
Top = 0
|
||||
Width = 202
|
||||
Height = 616
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 0
|
||||
object lblProtocol: TLabel
|
||||
Left = 4
|
||||
Top = 8
|
||||
Width = 42
|
||||
Height = 13
|
||||
Caption = 'Protocol:'
|
||||
end
|
||||
object lblHostName: TLabel
|
||||
Left = 4
|
||||
Top = 65
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'Host Name:'
|
||||
end
|
||||
object lblDatabase: TLabel
|
||||
Left = 4
|
||||
Top = 107
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Database:'
|
||||
end
|
||||
object lblUserName: TLabel
|
||||
Left = 4
|
||||
Top = 149
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'User Name:'
|
||||
end
|
||||
object lblPassword: TLabel
|
||||
Left = 4
|
||||
Top = 191
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Password:'
|
||||
end
|
||||
object lblTableName: TLabel
|
||||
Left = 7
|
||||
Top = 233
|
||||
Width = 61
|
||||
Height = 13
|
||||
Caption = 'Table Name:'
|
||||
end
|
||||
object lblMemoColumn: TLabel
|
||||
Left = 8
|
||||
Top = 275
|
||||
Width = 70
|
||||
Height = 13
|
||||
Caption = 'Memo Column:'
|
||||
end
|
||||
object lblBlobColumn: TLabel
|
||||
Left = 9
|
||||
Top = 316
|
||||
Width = 62
|
||||
Height = 13
|
||||
Caption = 'Blob Column:'
|
||||
end
|
||||
object cbxProtocol: TComboBox
|
||||
Left = 4
|
||||
Top = 24
|
||||
Width = 193
|
||||
Height = 21
|
||||
ItemHeight = 13
|
||||
TabOrder = 0
|
||||
Text = 'postgresql'
|
||||
OnChange = PropertiesChange
|
||||
Items.Strings = (
|
||||
'db2'
|
||||
'firebird-1.0'
|
||||
'firebird-1.5'
|
||||
'firebird-2.0'
|
||||
'interbase-5'
|
||||
'interbase-6'
|
||||
'mssql'
|
||||
'mysql'
|
||||
'mysql-4.0'
|
||||
'mysql-4.1'
|
||||
'oracle'
|
||||
'postgresql'
|
||||
'postgresql-8.0'
|
||||
'postgresql-8.1'
|
||||
'sqlite-2.8'
|
||||
'sqlite-3'
|
||||
'sybase')
|
||||
end
|
||||
object edtHostName: TEdit
|
||||
Left = 4
|
||||
Top = 81
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 1
|
||||
Text = 'localhost'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtDatabase: TEdit
|
||||
Left = 4
|
||||
Top = 123
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 2
|
||||
Text = 'zeoslib'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtUserName: TEdit
|
||||
Left = 4
|
||||
Top = 165
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 3
|
||||
Text = 'root'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtPassword: TEdit
|
||||
Left = 4
|
||||
Top = 207
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 4
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object btnConnect: TButton
|
||||
Left = 5
|
||||
Top = 371
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Connect'
|
||||
TabOrder = 6
|
||||
OnClick = btnConnectClick
|
||||
end
|
||||
object btnDisconnect: TButton
|
||||
Left = 5
|
||||
Top = 403
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Disconnect'
|
||||
TabOrder = 8
|
||||
OnClick = btnDisconnectClick
|
||||
end
|
||||
object btnOpen: TButton
|
||||
Left = 5
|
||||
Top = 443
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Open'
|
||||
TabOrder = 10
|
||||
OnClick = btnOpenClick
|
||||
end
|
||||
object btnClose: TButton
|
||||
Left = 5
|
||||
Top = 475
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Close'
|
||||
TabOrder = 12
|
||||
OnClick = btnCloseClick
|
||||
end
|
||||
object btnApplyUpdates: TButton
|
||||
Left = 5
|
||||
Top = 514
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Save Data'
|
||||
TabOrder = 14
|
||||
OnClick = btnApplyUpdatesClick
|
||||
end
|
||||
object btnCancelUpdates: TButton
|
||||
Left = 6
|
||||
Top = 546
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Cancel Updates'
|
||||
Enabled = False
|
||||
TabOrder = 5
|
||||
OnClick = btnCancelUpdatesClick
|
||||
end
|
||||
object edtTableName: TEdit
|
||||
Left = 4
|
||||
Top = 249
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 7
|
||||
Text = 'blob_values'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtMemoColumn: TEdit
|
||||
Left = 5
|
||||
Top = 291
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 9
|
||||
Text = 'b_text'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtBlobColumn: TEdit
|
||||
Left = 6
|
||||
Top = 332
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 11
|
||||
Text = 'b_image'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object btnLoadImage: TButton
|
||||
Left = 5
|
||||
Top = 586
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Load Image'
|
||||
TabOrder = 13
|
||||
OnClick = btnLoadImageClick
|
||||
end
|
||||
object cbxOidAsBlob: TCheckBox
|
||||
Left = 112
|
||||
Top = 49
|
||||
Width = 82
|
||||
Height = 17
|
||||
Caption = 'OID as BLOB'
|
||||
Checked = True
|
||||
Enabled = False
|
||||
State = cbChecked
|
||||
TabOrder = 15
|
||||
OnClick = cbxOidAsBlobClick
|
||||
end
|
||||
end
|
||||
object pnMain: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 530
|
||||
Height = 616
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 1
|
||||
object splMain: TSplitter
|
||||
Left = 0
|
||||
Top = 368
|
||||
Width = 530
|
||||
Height = 9
|
||||
Cursor = crVSplit
|
||||
Align = alBottom
|
||||
end
|
||||
object navMain: TDBNavigator
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 530
|
||||
Height = 27
|
||||
DataSource = dsMain
|
||||
Align = alTop
|
||||
TabOrder = 0
|
||||
end
|
||||
object gdMain: TDBGrid
|
||||
Left = 0
|
||||
Top = 27
|
||||
Width = 530
|
||||
Height = 341
|
||||
Align = alClient
|
||||
DataSource = dsMain
|
||||
TabOrder = 1
|
||||
TitleFont.Charset = DEFAULT_CHARSET
|
||||
TitleFont.Color = clWindowText
|
||||
TitleFont.Height = -11
|
||||
TitleFont.Name = 'MS Sans Serif'
|
||||
TitleFont.Style = []
|
||||
end
|
||||
object pnDetail: TPanel
|
||||
Left = 0
|
||||
Top = 377
|
||||
Width = 530
|
||||
Height = 239
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 2
|
||||
object splDetail: TSplitter
|
||||
Left = 257
|
||||
Top = 0
|
||||
Width = 9
|
||||
Height = 239
|
||||
end
|
||||
object memText: TDBMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 257
|
||||
Height = 239
|
||||
Align = alLeft
|
||||
DataField = 'b_text'
|
||||
DataSource = dsMain
|
||||
TabOrder = 0
|
||||
end
|
||||
object imgBlob: TDBImage
|
||||
Left = 266
|
||||
Top = 0
|
||||
Width = 264
|
||||
Height = 239
|
||||
Align = alClient
|
||||
DataField = 'b_image'
|
||||
DataSource = dsMain
|
||||
Stretch = True
|
||||
TabOrder = 1
|
||||
TabStop = False
|
||||
end
|
||||
end
|
||||
end
|
||||
object dsMain: TDataSource
|
||||
Left = 16
|
||||
Top = 80
|
||||
end
|
||||
object dlgOpenFile: TOpenDialog
|
||||
Title = 'Open'
|
||||
Left = 48
|
||||
Top = 80
|
||||
end
|
||||
end
|
285
ZEOSDBO/examples/blobs/ZBlobsMain.pas
Normal file
285
ZEOSDBO/examples/blobs/ZBlobsMain.pas
Normal file
@@ -0,0 +1,285 @@
|
||||
{*********************************************************}
|
||||
{ }
|
||||
{ Zeos Database Objects }
|
||||
{ Blobs Example Application }
|
||||
{ }
|
||||
{ Originally written by Sergey Seroukhov }
|
||||
{ }
|
||||
{*********************************************************}
|
||||
|
||||
{@********************************************************}
|
||||
{ Copyright (c) 1999-2006 Zeos Development Group }
|
||||
{ }
|
||||
{ License Agreement: }
|
||||
{ }
|
||||
{ This library is distributed in the hope that it will be }
|
||||
{ useful, but WITHOUT ANY WARRANTY; without even the }
|
||||
{ implied warranty of MERCHANTABILITY or FITNESS FOR }
|
||||
{ A PARTICULAR PURPOSE. See the GNU Lesser General }
|
||||
{ Public License for more details. }
|
||||
{ }
|
||||
{ The source code of the ZEOS Libraries and packages are }
|
||||
{ distributed under the Library GNU General Public }
|
||||
{ License (see the file COPYING / COPYING.ZEOS) }
|
||||
{ with the following modification: }
|
||||
{ As a special exception, the copyright holders of this }
|
||||
{ library give you permission to link this library with }
|
||||
{ independent modules to produce an executable, }
|
||||
{ regardless of the license terms of these independent }
|
||||
{ modules, and to copy and distribute the resulting }
|
||||
{ executable under terms of your choice, provided that }
|
||||
{ you also meet, for each linked independent module, }
|
||||
{ the terms and conditions of the license of that module. }
|
||||
{ An independent module is a module which is not derived }
|
||||
{ from or based on this library. If you modify this }
|
||||
{ library, you may extend this exception to your version }
|
||||
{ of the library, but you are not obligated to do so. }
|
||||
{ If you do not wish to do so, delete this exception }
|
||||
{ statement from your version. }
|
||||
{ }
|
||||
{ }
|
||||
{ The project web site is located on: }
|
||||
{ http://zeos.firmos.at (FORUM) }
|
||||
{ http://zeosbugs.firmos.at (BUGTRACKER) }
|
||||
{ svn://zeos.firmos.at/zeos/trunk (SVN Repository) }
|
||||
{ }
|
||||
{ http://www.sourceforge.net/projects/zeoslib. }
|
||||
{ http://www.zeoslib.sourceforge.net }
|
||||
{ }
|
||||
{ }
|
||||
{ }
|
||||
{ Zeos Development Group. }
|
||||
{********************************************************@}
|
||||
|
||||
unit ZBlobsMain;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
|
||||
SysUtils, {$IFDEF VER140}Types, {$ENDIF}Classes, DB,
|
||||
{$IFDEF LINUX}
|
||||
QGraphics, QControls, QForms, QDialogs,
|
||||
QStdCtrls, QExtCtrls, QDBCtrls, QGrids, QDBGrids,
|
||||
{$ELSE}
|
||||
Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids,
|
||||
{$ENDIF}
|
||||
ZConnection, ZDataset,
|
||||
ZDbcMySQL, ZDbcPostgreSQL, ZDbcInterbase6, ZDbcCache, ZSqlUpdate, ZSqlMetadata,
|
||||
ZDbcIntfs;
|
||||
|
||||
type
|
||||
{** Defines the main form of the application. }
|
||||
TfrmMain = class(TForm)
|
||||
pnControl: TPanel;
|
||||
pnMain: TPanel;
|
||||
navMain: TDBNavigator;
|
||||
gdMain: TDBGrid;
|
||||
pnDetail: TPanel;
|
||||
splMain: TSplitter;
|
||||
splDetail: TSplitter;
|
||||
memText: TDBMemo;
|
||||
lblProtocol: TLabel;
|
||||
cbxProtocol: TComboBox;
|
||||
lblHostName: TLabel;
|
||||
edtHostName: TEdit;
|
||||
lblDatabase: TLabel;
|
||||
edtDatabase: TEdit;
|
||||
lblUserName: TLabel;
|
||||
edtUserName: TEdit;
|
||||
edtPassword: TEdit;
|
||||
lblPassword: TLabel;
|
||||
btnConnect: TButton;
|
||||
btnDisconnect: TButton;
|
||||
btnOpen: TButton;
|
||||
btnClose: TButton;
|
||||
btnApplyUpdates: TButton;
|
||||
btnCancelUpdates: TButton;
|
||||
dsMain: TDataSource;
|
||||
imgBlob: TDBImage;
|
||||
lblTableName: TLabel;
|
||||
edtTableName: TEdit;
|
||||
lblMemoColumn: TLabel;
|
||||
edtMemoColumn: TEdit;
|
||||
lblBlobColumn: TLabel;
|
||||
edtBlobColumn: TEdit;
|
||||
btnLoadImage: TButton;
|
||||
dlgOpenFile: TOpenDialog;
|
||||
cbxOidAsBlob: TCheckBox;
|
||||
procedure cbxOidAsBlobClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure btnConnectClick(Sender: TObject);
|
||||
procedure btnDisconnectClick(Sender: TObject);
|
||||
procedure btnOpenClick(Sender: TObject);
|
||||
procedure btnCloseClick(Sender: TObject);
|
||||
procedure btnApplyUpdatesClick(Sender: TObject);
|
||||
procedure btnCancelUpdatesClick(Sender: TObject);
|
||||
procedure PropertiesChange(Sender: TObject);
|
||||
procedure btnLoadImageClick(Sender: TObject);
|
||||
private
|
||||
FConnection: TZConnection;
|
||||
FDataset: TZQuery;
|
||||
FMetadata: TZSqlMetadata;
|
||||
public
|
||||
property Connection: TZConnection read FConnection write FConnection;
|
||||
property Metadata:TZSqlMetadata read FMetadata write FMetadata;
|
||||
property Dataset: TZQuery read FDataset write FDataset;
|
||||
end;
|
||||
|
||||
var
|
||||
frmMain: TfrmMain;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF VER140}
|
||||
{$R *.xfm}
|
||||
{$ELSE}
|
||||
{$R *.dfm}
|
||||
{$ENDIF}
|
||||
|
||||
{**
|
||||
Initializes this form properties.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Connection := TZConnection.Create(Self);
|
||||
|
||||
Dataset := TZQuery.Create(Self);
|
||||
Dataset.Connection := Connection;
|
||||
Dataset.ReadOnly := False;
|
||||
// Dataset.CachedUpdates := True;
|
||||
|
||||
dsMain.Dataset := Dataset;
|
||||
PropertiesChange(Self);
|
||||
end;
|
||||
|
||||
{**
|
||||
Updates database properties.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.PropertiesChange(Sender: TObject);
|
||||
Var iIndex: Integer;
|
||||
begin
|
||||
Connection.Protocol := cbxProtocol.Text;
|
||||
Connection.HostName := edtHostName.Text;
|
||||
Connection.Database := edtDatabase.Text;
|
||||
Connection.User := edtUserName.Text;
|
||||
Connection.Password := edtPassword.Text;
|
||||
|
||||
Dataset.SQL.Text := 'SELECT * FROM ' + edtTableName.Text;
|
||||
memText.DataField := edtMemoColumn.Text;
|
||||
imgBlob.DataField := edtBlobColumn.Text;
|
||||
|
||||
cbxOidAsBlob.Enabled := (pos('postgre', cbxProtocol.Text) <> 0);
|
||||
|
||||
if cbxOidAsBlob.Enabled then
|
||||
cbxOidAsBlobClick(Sender)
|
||||
else
|
||||
Connection.Properties.Clear;
|
||||
|
||||
end;
|
||||
|
||||
{**
|
||||
Establishes a connection to SQL server.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnConnectClick(Sender: TObject);
|
||||
begin
|
||||
Connection.Connect;
|
||||
end;
|
||||
|
||||
{**
|
||||
Closes a connection to SQL server.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnDisconnectClick(Sender: TObject);
|
||||
begin
|
||||
Connection.Disconnect;
|
||||
end;
|
||||
|
||||
{**
|
||||
Opens a SQL query object.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnOpenClick(Sender: TObject);
|
||||
var sTyp: String;
|
||||
begin
|
||||
Dataset.Open;
|
||||
end;
|
||||
|
||||
{**
|
||||
Closes a SQL query object.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnCloseClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.Close;
|
||||
end;
|
||||
|
||||
{**
|
||||
Posts cached update to database from SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnApplyUpdatesClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.Post;
|
||||
// Dataset.CommitUpdates;
|
||||
end;
|
||||
|
||||
{**
|
||||
Cancel all previously made update in SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnCancelUpdatesClick(Sender: TObject);
|
||||
begin
|
||||
// Dataset.CancelUpdates;
|
||||
end;
|
||||
|
||||
{**
|
||||
Load an image from file and stores it into the blob column.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnLoadImageClick(Sender: TObject);
|
||||
var
|
||||
BlobStream: TStream;
|
||||
FileStream: TStream;
|
||||
begin
|
||||
if Dataset.Active then begin
|
||||
dlgOpenFile.Filter := 'Bitmap files (*.bmp)|*.BMP';
|
||||
if dlgOpenFile.Execute then begin
|
||||
begin
|
||||
if Dataset.State <> dsEdit then
|
||||
Dataset.Edit;
|
||||
|
||||
BlobStream := Dataset.CreateBlobStream(
|
||||
Dataset.FieldByName(edtBlobColumn.Text), bmWrite);
|
||||
try
|
||||
FileStream := TFileStream.Create(dlgOpenFile.FileName, fmOpenRead);
|
||||
try
|
||||
BlobStream.CopyFrom(FileStream, FileStream.Size);
|
||||
finally
|
||||
FileStream.Free;
|
||||
end;
|
||||
finally
|
||||
BlobStream.Free;
|
||||
end;
|
||||
|
||||
Dataset.Post;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.cbxOidAsBlobClick(Sender: TObject);
|
||||
begin
|
||||
if cbxOidAsBlob.Checked then
|
||||
Connection.Properties.Add('oidasblob=true')
|
||||
else
|
||||
Connection.Properties.Clear;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
312
ZEOSDBO/examples/blobs/ZBlobsMain.xfm
Normal file
312
ZEOSDBO/examples/blobs/ZBlobsMain.xfm
Normal file
@@ -0,0 +1,312 @@
|
||||
object frmMain: TfrmMain
|
||||
Left = 195
|
||||
Top = 110
|
||||
Width = 738
|
||||
Height = 603
|
||||
HorzScrollBar.Range = 202
|
||||
ActiveControl = cbxProtocol
|
||||
Caption = 'ZeosDBO Blobs Test'
|
||||
Color = clBackground
|
||||
OnCreate = FormCreate
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
TextWidth = 6
|
||||
object pnControl: TPanel
|
||||
Left = 536
|
||||
Top = 0
|
||||
Width = 202
|
||||
Height = 603
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 0
|
||||
object lblProtocol: TLabel
|
||||
Left = 4
|
||||
Top = 8
|
||||
Width = 42
|
||||
Height = 13
|
||||
Caption = 'Protocol:'
|
||||
end
|
||||
object cbxProtocol: TComboBox
|
||||
Left = 4
|
||||
Top = 24
|
||||
Width = 193
|
||||
Height = 21
|
||||
ItemHeight = 15
|
||||
Items.Strings = (
|
||||
'mysql'
|
||||
'postgresql'
|
||||
'postgresql-7.2'
|
||||
'interbase-5'
|
||||
'interbase-6'
|
||||
'firebird-1.0'
|
||||
'firebird-1.5'
|
||||
'mssql'
|
||||
'sybase'
|
||||
'oracle'
|
||||
'db2')
|
||||
ItemIndex = 1
|
||||
TabOrder = 0
|
||||
Text = 'postgresql'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblHostName: TLabel
|
||||
Left = 4
|
||||
Top = 50
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'Host Name:'
|
||||
end
|
||||
object edtHostName: TEdit
|
||||
Left = 4
|
||||
Top = 66
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 3
|
||||
Text = 'localhost'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblDatabase: TLabel
|
||||
Left = 4
|
||||
Top = 92
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Database:'
|
||||
end
|
||||
object edtDatabase: TEdit
|
||||
Left = 4
|
||||
Top = 108
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 5
|
||||
Text = 'zeoslib'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblUserName: TLabel
|
||||
Left = 4
|
||||
Top = 134
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'User Name:'
|
||||
end
|
||||
object edtUserName: TEdit
|
||||
Left = 4
|
||||
Top = 150
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 7
|
||||
Text = 'root'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtPassword: TEdit
|
||||
Left = 4
|
||||
Top = 192
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 8
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblPassword: TLabel
|
||||
Left = 4
|
||||
Top = 176
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Password:'
|
||||
end
|
||||
object btnConnect: TButton
|
||||
Left = 5
|
||||
Top = 356
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Connect'
|
||||
TabOrder = 10
|
||||
OnClick = btnConnectClick
|
||||
end
|
||||
object btnDisconnect: TButton
|
||||
Left = 5
|
||||
Top = 388
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Disconnect'
|
||||
TabOrder = 11
|
||||
OnClick = btnDisconnectClick
|
||||
end
|
||||
object btnOpen: TButton
|
||||
Left = 5
|
||||
Top = 428
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Open'
|
||||
TabOrder = 12
|
||||
OnClick = btnOpenClick
|
||||
end
|
||||
object btnClose: TButton
|
||||
Left = 5
|
||||
Top = 460
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Close'
|
||||
TabOrder = 13
|
||||
OnClick = btnCloseClick
|
||||
end
|
||||
object btnApplyUpdates: TButton
|
||||
Left = 5
|
||||
Top = 499
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Apply Updates'
|
||||
TabOrder = 14
|
||||
OnClick = btnApplyUpdatesClick
|
||||
end
|
||||
object btnCancelUpdates: TButton
|
||||
Left = 6
|
||||
Top = 531
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Cancel Updates'
|
||||
TabOrder = 15
|
||||
OnClick = btnCancelUpdatesClick
|
||||
end
|
||||
object lblTableName: TLabel
|
||||
Left = 7
|
||||
Top = 218
|
||||
Width = 61
|
||||
Height = 13
|
||||
Caption = 'Table Name:'
|
||||
end
|
||||
object edtTableName: TEdit
|
||||
Left = 4
|
||||
Top = 234
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 17
|
||||
Text = 'blob_values'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblMemoColumn: TLabel
|
||||
Left = 8
|
||||
Top = 260
|
||||
Width = 70
|
||||
Height = 13
|
||||
Caption = 'Memo Column:'
|
||||
end
|
||||
object edtMemoColumn: TEdit
|
||||
Left = 5
|
||||
Top = 276
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 19
|
||||
Text = 'b_text'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object lblBlobColumn: TLabel
|
||||
Left = 9
|
||||
Top = 301
|
||||
Width = 62
|
||||
Height = 13
|
||||
Caption = 'Blob Column:'
|
||||
end
|
||||
object edtBlobColumn: TEdit
|
||||
Left = 6
|
||||
Top = 317
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 21
|
||||
Text = 'b_image'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object btnLoadImage: TButton
|
||||
Left = 5
|
||||
Top = 571
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Load Image'
|
||||
TabOrder = 22
|
||||
OnClick = btnLoadImageClick
|
||||
end
|
||||
end
|
||||
object pnMain: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 536
|
||||
Height = 603
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 1
|
||||
object splMain: TSplitter
|
||||
Left = 0
|
||||
Top = 355
|
||||
Width = 536
|
||||
Height = 9
|
||||
Cursor = crVSplit
|
||||
Align = alBottom
|
||||
end
|
||||
object navMain: TDBNavigator
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 536
|
||||
Height = 27
|
||||
DataSource = dsMain
|
||||
Align = alTop
|
||||
TabOrder = 0
|
||||
end
|
||||
object gdMain: TDBGrid
|
||||
Left = 0
|
||||
Top = 27
|
||||
Width = 536
|
||||
Height = 328
|
||||
Align = alClient
|
||||
DataSource = dsMain
|
||||
TabOrder = 1
|
||||
TitleFont.Color = clBlack
|
||||
TitleFont.Height = 11
|
||||
TitleFont.Name = 'MS Shell Dlg'
|
||||
TitleFont.Pitch = fpVariable
|
||||
TitleFont.Style = []
|
||||
TitleFont.Weight = 40
|
||||
end
|
||||
object pnDetail: TPanel
|
||||
Left = 0
|
||||
Top = 364
|
||||
Width = 536
|
||||
Height = 239
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 2
|
||||
object splDetail: TSplitter
|
||||
Left = 257
|
||||
Top = 0
|
||||
Width = 9
|
||||
Height = 239
|
||||
end
|
||||
object memText: TDBMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 257
|
||||
Height = 239
|
||||
Align = alLeft
|
||||
DataField = 'b_text'
|
||||
DataSource = dsMain
|
||||
TabOrder = 0
|
||||
end
|
||||
object imgBlob: TDBImage
|
||||
Left = 266
|
||||
Top = 0
|
||||
Width = 270
|
||||
Height = 239
|
||||
Align = alClient
|
||||
DataField = 'b_image'
|
||||
DataSource = dsMain
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
object dsMain: TDataSource
|
||||
Left = 16
|
||||
Top = 80
|
||||
end
|
||||
object dlgOpenFile: TOpenDialog
|
||||
Title = 'Open'
|
||||
Left = 48
|
||||
Top = 80
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user