Стартовый пул
This commit is contained in:
127
ZEOSDBO/examples/simple/ZSimple.dof
Normal file
127
ZEOSDBO/examples/simple/ZSimple.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=1
|
||||
RemoteSymbols=1
|
||||
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
|
67
ZEOSDBO/examples/simple/ZSimple.dpr
Normal file
67
ZEOSDBO/examples/simple/ZSimple.dpr
Normal file
@@ -0,0 +1,67 @@
|
||||
{*********************************************************}
|
||||
{ }
|
||||
{ Zeos Database Objects }
|
||||
{ Simple 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 ZSimple;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
ZSimpleMain in 'ZSimpleMain.pas' {frmMain};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TfrmMain, frmMain);
|
||||
Application.Run;
|
||||
end.
|
||||
|
369
ZEOSDBO/examples/simple/ZSimpleMain.dfm
Normal file
369
ZEOSDBO/examples/simple/ZSimpleMain.dfm
Normal file
@@ -0,0 +1,369 @@
|
||||
object frmMain: TfrmMain
|
||||
Left = 205
|
||||
Top = 116
|
||||
Caption = 'ZeosDBO Simple Test'
|
||||
ClientHeight = 771
|
||||
ClientWidth = 894
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'MS Sans Serif'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object pnMain: TPanel
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 690
|
||||
Height = 771
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 0
|
||||
object splMain: TSplitter
|
||||
Left = 0
|
||||
Top = 121
|
||||
Width = 690
|
||||
Height = 8
|
||||
Cursor = crVSplit
|
||||
Align = alTop
|
||||
ExplicitWidth = 528
|
||||
end
|
||||
object splLog: TSplitter
|
||||
Left = 0
|
||||
Top = 649
|
||||
Width = 690
|
||||
Height = 8
|
||||
Cursor = crVSplit
|
||||
Align = alBottom
|
||||
ExplicitTop = 446
|
||||
ExplicitWidth = 528
|
||||
end
|
||||
object navMain: TDBNavigator
|
||||
Left = 0
|
||||
Top = 129
|
||||
Width = 690
|
||||
Height = 32
|
||||
DataSource = dsMain
|
||||
Align = alTop
|
||||
TabOrder = 0
|
||||
end
|
||||
object gdMain: TDBGrid
|
||||
Left = 0
|
||||
Top = 161
|
||||
Width = 690
|
||||
Height = 488
|
||||
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 memLog: TMemo
|
||||
Left = 0
|
||||
Top = 657
|
||||
Width = 690
|
||||
Height = 114
|
||||
Align = alBottom
|
||||
ReadOnly = True
|
||||
TabOrder = 2
|
||||
end
|
||||
object pcStatements: TPageControl
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 690
|
||||
Height = 121
|
||||
ActivePage = tshQuery
|
||||
Align = alTop
|
||||
TabOrder = 3
|
||||
object tshQuery: TTabSheet
|
||||
Caption = ' &Query '
|
||||
object memQuery: TMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 682
|
||||
Height = 93
|
||||
Align = alClient
|
||||
Lines.Strings = (
|
||||
'SELECT * FROM TSITE;')
|
||||
TabOrder = 0
|
||||
OnChange = PropertiesChange
|
||||
ExplicitLeft = -2
|
||||
ExplicitTop = -2
|
||||
end
|
||||
end
|
||||
object tshInsert: TTabSheet
|
||||
Caption = '&Insert '
|
||||
ImageIndex = 1
|
||||
object memInsert: TMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 682
|
||||
Height = 93
|
||||
Align = alClient
|
||||
Lines.Strings = (
|
||||
'')
|
||||
TabOrder = 0
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
end
|
||||
object tshUpdate: TTabSheet
|
||||
Caption = '&Update '
|
||||
ImageIndex = 2
|
||||
object memUpdate: TMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 682
|
||||
Height = 93
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
end
|
||||
object tshDelete: TTabSheet
|
||||
Caption = '&Delete '
|
||||
ImageIndex = 3
|
||||
object memDelete: TMemo
|
||||
Left = 0
|
||||
Top = 0
|
||||
Width = 682
|
||||
Height = 93
|
||||
Align = alClient
|
||||
Lines.Strings = (
|
||||
'')
|
||||
TabOrder = 0
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object pnControl: TPanel
|
||||
Left = 690
|
||||
Top = 0
|
||||
Width = 204
|
||||
Height = 771
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
TabOrder = 1
|
||||
object lblProtocol: TLabel
|
||||
Left = 8
|
||||
Top = 8
|
||||
Width = 42
|
||||
Height = 13
|
||||
Caption = 'Protocol:'
|
||||
end
|
||||
object lblHostName: TLabel
|
||||
Left = 8
|
||||
Top = 50
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'Host Name:'
|
||||
end
|
||||
object lblDatabase: TLabel
|
||||
Left = 8
|
||||
Top = 92
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Database:'
|
||||
end
|
||||
object lblUserName: TLabel
|
||||
Left = 8
|
||||
Top = 134
|
||||
Width = 56
|
||||
Height = 13
|
||||
Caption = 'User Name:'
|
||||
end
|
||||
object lblPassword: TLabel
|
||||
Left = 8
|
||||
Top = 176
|
||||
Width = 49
|
||||
Height = 13
|
||||
Caption = 'Password:'
|
||||
end
|
||||
object cbxProtocol: TComboBox
|
||||
Left = 8
|
||||
Top = 24
|
||||
Width = 193
|
||||
Height = 21
|
||||
ItemHeight = 13
|
||||
ItemIndex = 1
|
||||
TabOrder = 0
|
||||
Text = 'postgresql'
|
||||
OnChange = PropertiesChange
|
||||
Items.Strings = (
|
||||
'mysql'
|
||||
'postgresql'
|
||||
'postgresql-7.2'
|
||||
'interbase-5'
|
||||
'interbase-6'
|
||||
'firebird-1.0'
|
||||
'firebird-1.5'
|
||||
'mssql'
|
||||
'sybase'
|
||||
'oracle'
|
||||
'db2')
|
||||
end
|
||||
object edtHostName: TEdit
|
||||
Left = 8
|
||||
Top = 66
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 1
|
||||
Text = '10.0.0.10'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtDatabase: TEdit
|
||||
Left = 8
|
||||
Top = 108
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 2
|
||||
Text = 'firmtest'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtUserName: TEdit
|
||||
Left = 8
|
||||
Top = 150
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 3
|
||||
Text = 'firmos'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object edtPassword: TEdit
|
||||
Left = 8
|
||||
Top = 192
|
||||
Width = 193
|
||||
Height = 21
|
||||
TabOrder = 4
|
||||
Text = 'gimmehard'
|
||||
OnChange = PropertiesChange
|
||||
end
|
||||
object btnConnect: TButton
|
||||
Left = 8
|
||||
Top = 224
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Connect'
|
||||
TabOrder = 5
|
||||
OnClick = btnConnectClick
|
||||
end
|
||||
object btnDisconnect: TButton
|
||||
Left = 8
|
||||
Top = 256
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Disconnect'
|
||||
TabOrder = 6
|
||||
OnClick = btnDisconnectClick
|
||||
end
|
||||
object btnOpen: TButton
|
||||
Left = 6
|
||||
Top = 297
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Open'
|
||||
TabOrder = 7
|
||||
OnClick = btnOpenClick
|
||||
end
|
||||
object btnClose: TButton
|
||||
Left = 8
|
||||
Top = 328
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Close'
|
||||
TabOrder = 8
|
||||
OnClick = btnCloseClick
|
||||
end
|
||||
object btnExecute: TButton
|
||||
Left = 8
|
||||
Top = 368
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Execute'
|
||||
TabOrder = 9
|
||||
OnClick = btnExecuteClick
|
||||
end
|
||||
object btnPrint: TButton
|
||||
Left = 8
|
||||
Top = 464
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Print ResultSet'
|
||||
TabOrder = 10
|
||||
OnClick = btnPrintClick
|
||||
end
|
||||
object btnFilter: TButton
|
||||
Left = 8
|
||||
Top = 400
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = 'Switch &Filter'
|
||||
TabOrder = 11
|
||||
OnClick = btnFilterClick
|
||||
end
|
||||
object btnLocate: TButton
|
||||
Left = 8
|
||||
Top = 432
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Locate'
|
||||
TabOrder = 12
|
||||
OnClick = btnLocateClick
|
||||
end
|
||||
object btnApplyUpdates: TButton
|
||||
Left = 8
|
||||
Top = 504
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Apply Updates'
|
||||
TabOrder = 13
|
||||
OnClick = btnApplyUpdatesClick
|
||||
end
|
||||
object btnCancelUpdates: TButton
|
||||
Left = 8
|
||||
Top = 536
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = '&Cancel Updates'
|
||||
TabOrder = 14
|
||||
OnClick = btnCancelUpdatesClick
|
||||
end
|
||||
object ButtonRefresh: TButton
|
||||
Left = 6
|
||||
Top = 608
|
||||
Width = 193
|
||||
Height = 25
|
||||
Caption = 'Refresh'
|
||||
TabOrder = 15
|
||||
OnClick = ButtonRefreshClick
|
||||
end
|
||||
end
|
||||
object dsMain: TDataSource
|
||||
Left = 16
|
||||
Top = 64
|
||||
end
|
||||
object ZSQLMonitor: TZSQLMonitor
|
||||
Active = True
|
||||
MaxTraceCount = 100
|
||||
OnTrace = ZSQLMonitorTrace
|
||||
OnLogTrace = ZSQLMonitorLogTrace
|
||||
Left = 176
|
||||
Top = 296
|
||||
end
|
||||
object ZQueryZ: TZQuery
|
||||
Params = <>
|
||||
Left = 208
|
||||
Top = 384
|
||||
end
|
||||
object ZSequence: TZSequence
|
||||
Left = 344
|
||||
Top = 352
|
||||
end
|
||||
end
|
392
ZEOSDBO/examples/simple/ZSimpleMain.pas
Normal file
392
ZEOSDBO/examples/simple/ZSimpleMain.pas
Normal file
@@ -0,0 +1,392 @@
|
||||
{*********************************************************}
|
||||
{ }
|
||||
{ Zeos Database Objects }
|
||||
{ Simple 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 ZSimpleMain;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, {$IFDEF VER140} Variants, {$ENDIF} Classes, Graphics, Controls, Forms,
|
||||
Dialogs, Grids, DBGrids, DBCtrls, ExtCtrls, StdCtrls, ZConnection, ZDataset,
|
||||
ZDbcCache, ZAbstractRODataset, ZDbcMySQL, ZDbcPostgreSQL, DB, ZSqlUpdate,
|
||||
ComCtrls, ZDbcInterbase6, ZSqlMonitor, ZAbstractDataset, ZSequence;
|
||||
|
||||
type
|
||||
{** Implements the main application form. }
|
||||
TfrmMain = class(TForm)
|
||||
pnMain: TPanel;
|
||||
splMain: TSplitter;
|
||||
navMain: TDBNavigator;
|
||||
gdMain: TDBGrid;
|
||||
pnControl: TPanel;
|
||||
lblProtocol: TLabel;
|
||||
cbxProtocol: TComboBox;
|
||||
lblHostName: TLabel;
|
||||
edtHostName: TEdit;
|
||||
lblDatabase: TLabel;
|
||||
edtDatabase: TEdit;
|
||||
lblUserName: TLabel;
|
||||
edtUserName: TEdit;
|
||||
lblPassword: TLabel;
|
||||
edtPassword: TEdit;
|
||||
btnConnect: TButton;
|
||||
btnDisconnect: TButton;
|
||||
btnOpen: TButton;
|
||||
btnClose: TButton;
|
||||
btnExecute: TButton;
|
||||
dsMain: TDataSource;
|
||||
memLog: TMemo;
|
||||
splLog: TSplitter;
|
||||
btnPrint: TButton;
|
||||
btnFilter: TButton;
|
||||
btnLocate: TButton;
|
||||
btnApplyUpdates: TButton;
|
||||
btnCancelUpdates: TButton;
|
||||
pcStatements: TPageControl;
|
||||
tshQuery: TTabSheet;
|
||||
memQuery: TMemo;
|
||||
tshInsert: TTabSheet;
|
||||
tshUpdate: TTabSheet;
|
||||
tshDelete: TTabSheet;
|
||||
memInsert: TMemo;
|
||||
memUpdate: TMemo;
|
||||
memDelete: TMemo;
|
||||
ZSQLMonitor: TZSQLMonitor;
|
||||
ButtonRefresh: TButton;
|
||||
ZQueryZ: TZQuery;
|
||||
ZSequence: TZSequence;
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure ButtonRefreshClick(Sender: TObject);
|
||||
procedure ZSQLMonitorTrace(Sender: TObject; Event: TZLoggingEvent;
|
||||
var LogTrace: Boolean);
|
||||
procedure ZSQLMonitorLogTrace(Sender: TObject; Event: TZLoggingEvent);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure btnConnectClick(Sender: TObject);
|
||||
procedure btnDisconnectClick(Sender: TObject);
|
||||
procedure btnOpenClick(Sender: TObject);
|
||||
procedure btnCloseClick(Sender: TObject);
|
||||
procedure btnExecuteClick(Sender: TObject);
|
||||
procedure btnPrintClick(Sender: TObject);
|
||||
procedure DataSetCalcFields(DataSet: TDataSet);
|
||||
procedure DataSetFilterRecord(DataSet: TDataSet; var Accept: Boolean);
|
||||
procedure btnFilterClick(Sender: TObject);
|
||||
procedure btnLocateClick(Sender: TObject);
|
||||
procedure btnApplyUpdatesClick(Sender: TObject);
|
||||
procedure btnCancelUpdatesClick(Sender: TObject);
|
||||
procedure PropertiesChange(Sender: TObject);
|
||||
private
|
||||
FConnection: TZConnection;
|
||||
FDataset: TZQuery;
|
||||
FUpdateSQL: TZUpdateSQL;
|
||||
public
|
||||
property Connection: TZConnection read FConnection write FConnection;
|
||||
property Dataset: TZQuery read FDataset write FDataset;
|
||||
property UpdateSQL: TZUpdateSQL read FUpdateSQL write FUpdateSQL;
|
||||
end;
|
||||
|
||||
var
|
||||
frmMain: TfrmMain;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
{**
|
||||
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 := FConnection;
|
||||
ZSequence.Connection:=Connection;
|
||||
ZSequence.SequenceName:='t1_id_seq';
|
||||
DataSet.sequence:=ZSequence;
|
||||
Dataset.SequenceField:='ID';
|
||||
|
||||
// Dataset.RequestLive := True;
|
||||
// Dataset.CachedUpdates := True;
|
||||
// Dataset.IsUniDirectional := True;
|
||||
|
||||
dataset.SQL.Add('SELECT * FROM tsite');
|
||||
// Dataset.OnCalcFields := DataSetCalcFields;
|
||||
// Dataset.OnFilterRecord := DataSetFilterRecord;
|
||||
// Dataset.Filtered := True;
|
||||
dsMain.Dataset := Dataset;
|
||||
|
||||
UpdateSQL := TZUpdateSQL.Create(Self);
|
||||
UpdateSQL.DeleteSQL.Add('DELETE FROM T1 WHERE id=:OLD_ID');
|
||||
UpdateSQL.ModifySQL.Add('UPDATE T1 SET ID=:ID, A=:A, B=:B WHERE id=:OLD_ID');
|
||||
UpdateSQL.InsertSQL.Add('INSERT INTO T1 (id,a,b) VALUES (:ID,55, 66)');
|
||||
UpdateSQL.RefreshSQL.Add('SELECT * FROM T1 WHERE ID=:OLD_ID');
|
||||
UpdateSQL.Refresh_OLD_ID_SEQ:=true;
|
||||
|
||||
Dataset.UpdateObject:=UpdateSQL;
|
||||
|
||||
|
||||
PropertiesChange(Self);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
Connection.Free;
|
||||
end;
|
||||
|
||||
{**
|
||||
Reads different properties from form controls.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.PropertiesChange(Sender: TObject);
|
||||
begin
|
||||
Connection.Protocol := cbxProtocol.Text;
|
||||
Connection.HostName := edtHostName.Text;
|
||||
Connection.Database := edtDatabase.Text;
|
||||
Connection.User := edtUserName.Text;
|
||||
Connection.Password := edtPassword.Text;
|
||||
// Dataset.SQL := memQuery.Lines;
|
||||
Dataset.Fields.Clear;
|
||||
|
||||
// UpdateSQL.InsertSQL := memInsert.Lines;
|
||||
// UpdateSQL.ModifySQL := memUpdate.Lines;
|
||||
// UpdateSQL.DeleteSQL := memDelete.Lines;
|
||||
end;
|
||||
|
||||
procedure TfrmMain.ZSQLMonitorLogTrace(Sender: TObject; Event: TZLoggingEvent);
|
||||
begin
|
||||
memLog.Lines.Add(Event.AsString);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.ZSQLMonitorTrace(Sender: TObject; Event: TZLoggingEvent; var LogTrace: Boolean);
|
||||
begin
|
||||
// memLog.Lines.Add(Event.AsString);
|
||||
end;
|
||||
|
||||
{**
|
||||
Establishes a connection to SQL server.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnConnectClick(Sender: TObject);
|
||||
begin
|
||||
Connection.Connect;
|
||||
ShowMessage(inttostr(Connection.Port));
|
||||
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 and read data from server.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnOpenClick(Sender: TObject);
|
||||
var
|
||||
I: Integer;
|
||||
FieldDefs: TFieldDefs;
|
||||
CalcField: TStringField;
|
||||
begin
|
||||
Dataset.Close;
|
||||
FieldDefs := Dataset.FieldDefs;
|
||||
FieldDefs.Update;
|
||||
|
||||
if Dataset.FindField('Calculated') = nil then
|
||||
begin
|
||||
for I := 0 to FieldDefs.Count - 1 do
|
||||
FieldDefs[I].CreateField(Dataset).DataSet := Dataset;
|
||||
|
||||
CalcField := TStringField.Create(nil);
|
||||
CalcField.Size := 10;
|
||||
CalcField.FieldName := 'Calculated';
|
||||
CalcField.FieldKind := fkCalculated;
|
||||
CalcField.Visible := True;
|
||||
CalcField.DataSet := Dataset;
|
||||
end;
|
||||
|
||||
Dataset.Open;
|
||||
end;
|
||||
|
||||
{**
|
||||
Closes the SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnCloseClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.Close;
|
||||
end;
|
||||
|
||||
{**
|
||||
Executes the SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnExecuteClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.ExecSQL;
|
||||
end;
|
||||
|
||||
{**
|
||||
Prints SQL query field values.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnPrintClick(Sender: TObject);
|
||||
var
|
||||
I: Integer;
|
||||
Temp: string;
|
||||
begin
|
||||
Temp := '';
|
||||
for I := 0 to Dataset.FieldCount - 1 do
|
||||
begin
|
||||
if Temp <> '' then Temp := Temp + ',';
|
||||
Temp := Temp + '"' + Dataset.Fields[I].DisplayName + '"';
|
||||
end;
|
||||
memLog.Lines.Append(Temp);
|
||||
memLog.Lines.Append('------------------------------------------');
|
||||
|
||||
Dataset.First;
|
||||
while not Dataset.EOF do
|
||||
begin
|
||||
Temp := '';
|
||||
for I := 0 to Dataset.FieldCount - 1 do
|
||||
begin
|
||||
if Temp <> '' then Temp := Temp + ',';
|
||||
Temp := Temp + '"' + Dataset.Fields[I].AsString + '"';
|
||||
end;
|
||||
memLog.Lines.Append(Temp);
|
||||
|
||||
Dataset.Next;
|
||||
end;
|
||||
memLog.Lines.Append('');
|
||||
end;
|
||||
|
||||
procedure TfrmMain.ButtonRefreshClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.Refresh;
|
||||
end;
|
||||
|
||||
{**
|
||||
Fills a dataset calculated fields.
|
||||
@param Dataset a dataset sender object reference.
|
||||
}
|
||||
procedure TfrmMain.DataSetCalcFields(DataSet: TDataSet);
|
||||
begin
|
||||
Dataset.FieldByName('Calculated').AsString :=
|
||||
Copy('### ' + Dataset.Fields[0].AsString + ' ###', 1, 10);
|
||||
end;
|
||||
|
||||
{**
|
||||
Filters the dataset records.
|
||||
@param Dataset a dataset sender object reference.
|
||||
@param Accept <code>True</code> to accept the field
|
||||
and <code>False</code> to hide it.
|
||||
}
|
||||
procedure TfrmMain.DataSetFilterRecord(DataSet: TDataSet;
|
||||
var Accept: Boolean);
|
||||
begin
|
||||
Accept := not ((Dataset.Fields[0].AsInteger mod 3) = 0);
|
||||
end;
|
||||
|
||||
{**
|
||||
Sets a new filter for SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnFilterClick(Sender: TObject);
|
||||
begin
|
||||
// Dataset.Filtered := not Dataset.Filtered;
|
||||
{
|
||||
if Dataset.ShowRecordTypes = [utModified, utInserted, utUnmodified] then
|
||||
Dataset.ShowRecordTypes := [utModified, utDeleted]
|
||||
else Dataset.ShowRecordTypes := [utModified, utInserted, utUnmodified];
|
||||
}
|
||||
end;
|
||||
|
||||
{**
|
||||
Locates a record in SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnLocateClick(Sender: TObject);
|
||||
begin
|
||||
// Dataset.Locate('0, fld,"Calculated"',
|
||||
// VarArrayOf([7,'Mango','### 7 ###']), []);
|
||||
// Dataset.Locate('ID, 1', VarArrayOf([7,'MAN']),
|
||||
// [loCaseInsensitive, loPartialKey]);
|
||||
// Dataset.Locate('"Id", "FLD"', VarArrayOf([7,'MANGO']), [loCaseInsensitive]);
|
||||
|
||||
//// Dataset.Lookup('id, fld', VarArrayOf([7,'Mango']), '"Calculated"')
|
||||
end;
|
||||
|
||||
{**
|
||||
Posts query updates to SQL server.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnApplyUpdatesClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.ApplyUpdates;
|
||||
Dataset.CommitUpdates;
|
||||
end;
|
||||
|
||||
{**
|
||||
Cancels all previously made update in SQL query.
|
||||
@param Sender an event sender object reference.
|
||||
}
|
||||
procedure TfrmMain.btnCancelUpdatesClick(Sender: TObject);
|
||||
begin
|
||||
Dataset.CancelUpdates;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user