Sie sind auf Seite 1von 169

MySQL Data Access

Components

Core Lab
I MySQL Data Access Components

Table of Contents

.....................................................................................................................................................................11
Overview
.....................................................................................................................................................................13
Compatibility
.....................................................................................................................................................................14
Components
.....................................................................................................................................................................15
Demos
.....................................................................................................................................................................16
Hierarchy chart
.....................................................................................................................................................................17
Writing GUI applications with MyDAC
.....................................................................................................................................................................18
Installation
.....................................................................................................................................................................19
Trial version restrictions
Using.....................................................................................................................................................................20
MyDAC
Migration
.................................................................................................................................................................
from BDE 20
Working
.................................................................................................................................................................
with master/detail relationships 23
Using.................................................................................................................................................................
DBMonitor 25
Secure
.................................................................................................................................................................
connections 26
Using.................................................................................................................................................................
Embedded server 27
Using.................................................................................................................................................................
MyBuilder Add-in 29

.....................................................................................................................................................................30
MyDAC Alphabetical Object and Component Listing
EDAError
................................................................................................................................................................. 30
Description
............................................................................................................................................................ 30
Properties
............................................................................................................................................................ 30
ErrorCode
.................................................................................................................................................................. 30
TDAColumn
................................................................................................................................................................. 31
Description
............................................................................................................................................................ 31
Properties
............................................................................................................................................................ 31
DataType
.................................................................................................................................................................. 31
Name
.................................................................................................................................................................. 31
TDAColumns
................................................................................................................................................................. 32
Description
............................................................................................................................................................ 32
Properties
............................................................................................................................................................ 32
Items
.................................................................................................................................................................. 32
TBlob................................................................................................................................................................. 33
Description
............................................................................................................................................................ 33
Properties
............................................................................................................................................................ 33
AsString
.................................................................................................................................................................. 33
AsWideString
.................................................................................................................................................................. 33

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Contents II

Size
.................................................................................................................................................................. 33
IsUnicode
.................................................................................................................................................................. 33
Methods
............................................................................................................................................................ 34
Assign
.................................................................................................................................................................. 34
Clear
.................................................................................................................................................................. 34
LoadFromFile
.................................................................................................................................................................. 34
LoadFromSream
.................................................................................................................................................................. 34
Read
.................................................................................................................................................................. 35
SaveToFile
.................................................................................................................................................................. 35
SaveToStream
.................................................................................................................................................................. 35
Truncate
.................................................................................................................................................................. 35
Write
.................................................................................................................................................................. 35
TCustomConnectDialog
................................................................................................................................................................. 37
Description
............................................................................................................................................................ 37
Properties
............................................................................................................................................................ 37
CancelButton
.................................................................................................................................................................. 37
Caption
.................................................................................................................................................................. 37
ConnectButton
.................................................................................................................................................................. 37
DialogClass
.................................................................................................................................................................. 37
LabelSet
.................................................................................................................................................................. 38
PasswordLabel
.................................................................................................................................................................. 38
Retries
.................................................................................................................................................................. 38
SavePassword
.................................................................................................................................................................. 38
ServerLabel
.................................................................................................................................................................. 38
StoreLogInfo
.................................................................................................................................................................. 38
UsernameLabel
.................................................................................................................................................................. 39
Methods
............................................................................................................................................................ 39
Execute
.................................................................................................................................................................. 39
GetServerList
.................................................................................................................................................................. 39
TCustomDAConnection
................................................................................................................................................................. 40
Description
............................................................................................................................................................ 40
Properties
............................................................................................................................................................ 40
ConnectDialog
.................................................................................................................................................................. 40
InTransaction
.................................................................................................................................................................. 40
Password
.................................................................................................................................................................. 40
Pooling
.................................................................................................................................................................. 41
PoolingOptions
.................................................................................................................................................................. 41
Server
.................................................................................................................................................................. 42
Username
.................................................................................................................................................................. 42
Methods
............................................................................................................................................................ 42
ApplyUpdates
.................................................................................................................................................................. 42
Commit
.................................................................................................................................................................. 43
Connect
.................................................................................................................................................................. 43
CreateDataSet
.................................................................................................................................................................. 43
CreateSQL
.................................................................................................................................................................. 44
Disconnect
.................................................................................................................................................................. 44
ExecSQL
.................................................................................................................................................................. 44
GetDatabaseNames
.................................................................................................................................................................. 44
GetTableNames
.................................................................................................................................................................. 45
GetStoredProcNames
.................................................................................................................................................................. 45
Rollback
.................................................................................................................................................................. 45
StartTransaction
.................................................................................................................................................................. 46
Events
............................................................................................................................................................ 46

MySQL Data Access Components, Copyright © 1998-2003 Core Lab

II
III MySQL Data Access Components

OnError
.................................................................................................................................................................. 46
DADataAdapter
................................................................................................................................................................. 47
Description
............................................................................................................................................................ 47
Properties
............................................................................................................................................................ 47
DataSet
.................................................................................................................................................................. 47
Methods
............................................................................................................................................................ 47
Fill
.................................................................................................................................................................. 47
Update
.................................................................................................................................................................. 48
TCustomDADataSet
................................................................................................................................................................. 49
Description
............................................................................................................................................................ 49
Properties
............................................................................................................................................................ 49
AutoCommit
.................................................................................................................................................................. 49
BaseSQL
.................................................................................................................................................................. 49
Connection
.................................................................................................................................................................. 49
Debug
.................................................................................................................................................................. 49
DetailFields
.................................................................................................................................................................. 50
FetchAll
.................................................................................................................................................................. 50
FetchRows
.................................................................................................................................................................. 51
FilterSQL
.................................................................................................................................................................. 51
FinalSQL
.................................................................................................................................................................. 51
IsQuery
.................................................................................................................................................................. 51
MacroCount
.................................................................................................................................................................. 51
Macros
.................................................................................................................................................................. 52
MasterFields
.................................................................................................................................................................. 52
MasterSource
.................................................................................................................................................................. 52
Options
.................................................................................................................................................................. 53
ParamCheck
.................................................................................................................................................................. 54
ParamCount
.................................................................................................................................................................. 54
Params
.................................................................................................................................................................. 54
ReadOnly
.................................................................................................................................................................. 55
RefreshOptions
.................................................................................................................................................................. 55
RowsAffected
.................................................................................................................................................................. 55
SQL
.................................................................................................................................................................. 55
SQLDelete
.................................................................................................................................................................. 56
SQLInsert
.................................................................................................................................................................. 56
SQLRefresh
.................................................................................................................................................................. 56
SQLUpdate
.................................................................................................................................................................. 57
UniDirectional
.................................................................................................................................................................. 57
UpdateObject
.................................................................................................................................................................. 57
Methods
............................................................................................................................................................ 58
AddWhere
.................................................................................................................................................................. 58
DeleteWhere
.................................................................................................................................................................. 58
Execute
.................................................................................................................................................................. 58
Executing
.................................................................................................................................................................. 58
Fetched
.................................................................................................................................................................. 58
Fetching
.................................................................................................................................................................. 59
FetchingAll
.................................................................................................................................................................. 59
FindMacro
.................................................................................................................................................................. 59
FindParam
.................................................................................................................................................................. 59
GetBlob
.................................................................................................................................................................. 60
GetDataType
.................................................................................................................................................................. 60
GetFieldObject
.................................................................................................................................................................. 60
GetFieldPrecision
.................................................................................................................................................................. 60

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Contents IV

GetFieldScale
.................................................................................................................................................................. 60
GetOrderBy
.................................................................................................................................................................. 61
MacroByName
.................................................................................................................................................................. 61
ParamByName
.................................................................................................................................................................. 61
Prepare
.................................................................................................................................................................. 62
RefreshRecord
.................................................................................................................................................................. 62
RestoreSQL
.................................................................................................................................................................. 62
SetOrderBy
.................................................................................................................................................................. 62
Events
............................................................................................................................................................ 63
AfterExecute
.................................................................................................................................................................. 63
AfterUpdateExecute
.................................................................................................................................................................. 63
BeforeUpdateExecute
.................................................................................................................................................................. 63
TCustomDASQL
................................................................................................................................................................. 64
Description
............................................................................................................................................................ 64
Properties
............................................................................................................................................................ 64
AutoCommit
.................................................................................................................................................................. 64
Connection
.................................................................................................................................................................. 64
Debug
.................................................................................................................................................................. 64
FinalSQL
.................................................................................................................................................................. 65
MacroCount
.................................................................................................................................................................. 65
Macros
.................................................................................................................................................................. 65
ParamCheck
.................................................................................................................................................................. 65
ParamCount
.................................................................................................................................................................. 65
Params
.................................................................................................................................................................. 66
ParamValues
.................................................................................................................................................................. 66
Prepared
.................................................................................................................................................................. 67
RowsAffected
.................................................................................................................................................................. 67
SQL
.................................................................................................................................................................. 67
Methods
............................................................................................................................................................ 67
Execute
.................................................................................................................................................................. 67
Executing
.................................................................................................................................................................. 67
FindMacro
.................................................................................................................................................................. 67
FindParam
.................................................................................................................................................................. 68
MacroByName
.................................................................................................................................................................. 68
ParamByName
.................................................................................................................................................................. 68
Prepare
.................................................................................................................................................................. 69
UnPrepare
.................................................................................................................................................................. 69
WaitExecuting
.................................................................................................................................................................. 69
Events
............................................................................................................................................................ 69
AfterExecute
.................................................................................................................................................................. 69
TCustomDASQLMonitor
................................................................................................................................................................. 70
Description
............................................................................................................................................................ 70
Properties
............................................................................................................................................................ 70
Active
.................................................................................................................................................................. 70
Options
.................................................................................................................................................................. 70
TraceFlags
.................................................................................................................................................................. 71
Events
............................................................................................................................................................ 71
OnSQL
.................................................................................................................................................................. 71
TCustomDAUpdateSQL
................................................................................................................................................................. 72
Description
............................................................................................................................................................ 72
Properties
............................................................................................................................................................ 72
Dataset
.................................................................................................................................................................. 72
DeleteSQL
.................................................................................................................................................................. 72

MySQL Data Access Components, Copyright © 1998-2003 Core Lab

IV
V MySQL Data Access Components

InsertSQL
.................................................................................................................................................................. 72
ModifySQL
.................................................................................................................................................................. 73
RefreshSQL
.................................................................................................................................................................. 73
SQL
.................................................................................................................................................................. 73
Methods
............................................................................................................................................................ 73
Apply
.................................................................................................................................................................. 73
ExecSQL
.................................................................................................................................................................. 74
TDAParam
................................................................................................................................................................. 75
Description
............................................................................................................................................................ 75
Properties
............................................................................................................................................................ 75
AsBlob
.................................................................................................................................................................. 75
AsBlobRef
.................................................................................................................................................................. 75
AsFloat
.................................................................................................................................................................. 75
AsInteger
.................................................................................................................................................................. 76
AsMemo
.................................................................................................................................................................. 76
AsMemoRef
.................................................................................................................................................................. 76
AsString
.................................................................................................................................................................. 76
AsWideString
.................................................................................................................................................................. 76
DataType
.................................................................................................................................................................. 76
IsNull
.................................................................................................................................................................. 77
ParamType
.................................................................................................................................................................. 77
Size
.................................................................................................................................................................. 77
Value
.................................................................................................................................................................. 77
Methods
............................................................................................................................................................ 77
LoadFromFile
.................................................................................................................................................................. 77
LoadFromStream
.................................................................................................................................................................. 78
TDAParams
................................................................................................................................................................. 79
Description
............................................................................................................................................................ 79
Properties
............................................................................................................................................................ 79
Items
.................................................................................................................................................................. 79
Methods
............................................................................................................................................................ 79
FindParam
.................................................................................................................................................................. 79
ParamByName
.................................................................................................................................................................. 79
TMacro
................................................................................................................................................................. 81
Description
............................................................................................................................................................ 81
Properties
............................................................................................................................................................ 81
Active
.................................................................................................................................................................. 81
AsDateTime
.................................................................................................................................................................. 81
AsFloat
.................................................................................................................................................................. 81
AsInteger
.................................................................................................................................................................. 82
AsString
.................................................................................................................................................................. 82
Name
.................................................................................................................................................................. 82
Value
.................................................................................................................................................................. 82
TMacros
................................................................................................................................................................. 83
Description
............................................................................................................................................................ 83
Properties
............................................................................................................................................................ 83
Count
.................................................................................................................................................................. 83
Items
.................................................................................................................................................................. 83
Methods
............................................................................................................................................................ 83
FindMacro
.................................................................................................................................................................. 83
MacroByName
.................................................................................................................................................................. 83
TMemDataSet
................................................................................................................................................................. 85

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Contents VI

Description
............................................................................................................................................................ 85
Properties
............................................................................................................................................................ 85
CachedUpdates
.................................................................................................................................................................. 85
IndexFieldNames
.................................................................................................................................................................. 86
LocalConstraints
.................................................................................................................................................................. 86
LocalUpdate
.................................................................................................................................................................. 86
Prepared
.................................................................................................................................................................. 86
UpdateRecordTypes
.................................................................................................................................................................. 87
UpdatesPending
.................................................................................................................................................................. 87
Methods
............................................................................................................................................................ 87
ApplyUpdates
.................................................................................................................................................................. 87
CancelUpdates
.................................................................................................................................................................. 88
CommitUpdates
.................................................................................................................................................................. 88
DeferredPost
.................................................................................................................................................................. 89
Locate
.................................................................................................................................................................. 89
LocateEx
.................................................................................................................................................................. 89
Prepare
.................................................................................................................................................................. 90
RestoreUpdates
.................................................................................................................................................................. 90
RevertRecord
.................................................................................................................................................................. 91
UnPrepare
.................................................................................................................................................................. 91
UpdateResult
.................................................................................................................................................................. 91
UpdateStatus
.................................................................................................................................................................. 91
Events
............................................................................................................................................................ 92
OnUpdateError
.................................................................................................................................................................. 92
OnUpdateRecord
.................................................................................................................................................................. 93
TSharedObject
................................................................................................................................................................. 94
Description
............................................................................................................................................................ 94
Properties
............................................................................................................................................................ 94
RefCount
.................................................................................................................................................................. 94
Methods
............................................................................................................................................................ 94
AddRef
.................................................................................................................................................................. 94
Release
.................................................................................................................................................................. 94
TVirtualTable
................................................................................................................................................................. 95
Description
............................................................................................................................................................ 95
Properties
............................................................................................................................................................ 95
Options
.................................................................................................................................................................. 95
Methods
............................................................................................................................................................ 95
AddField
.................................................................................................................................................................. 95
Assign
.................................................................................................................................................................. 96
Clear
.................................................................................................................................................................. 96
DeleteField
.................................................................................................................................................................. 96
DeleteFields
.................................................................................................................................................................. 97
LoadFromFile
.................................................................................................................................................................. 97
LoadFromStream
.................................................................................................................................................................. 97
SaveToFile
.................................................................................................................................................................. 97
SaveToStream
.................................................................................................................................................................. 97
EMyError
................................................................................................................................................................. 98
Description
............................................................................................................................................................ 98
Properties
............................................................................................................................................................ 98
ErrorCode
.................................................................................................................................................................. 98
MyDataAdapter
................................................................................................................................................................. 99
Description
............................................................................................................................................................ 99

MySQL Data Access Components, Copyright © 1998-2003 Core Lab

VI
VII MySQL Data Access Components

TCustomMyDataSet
................................................................................................................................................................. 100
Description
............................................................................................................................................................ 100
Properties
............................................................................................................................................................ 100
..................................................................................................................................................................
CommandTimeout 100
..................................................................................................................................................................
Connection 100
..................................................................................................................................................................
InsertId 101
..................................................................................................................................................................
Options 101
Methods
............................................................................................................................................................ 102
..................................................................................................................................................................
Lock 102
..................................................................................................................................................................
LockTable 103
..................................................................................................................................................................
UnlockTable 104
TCustomMyTable
................................................................................................................................................................. 105
Description
............................................................................................................................................................ 105
Properties
............................................................................................................................................................ 105
..................................................................................................................................................................
IndexDefs 105
..................................................................................................................................................................
Limit 105
..................................................................................................................................................................
Offset 105
..................................................................................................................................................................
OrderFields 106
..................................................................................................................................................................
TableName 106
Methods
............................................................................................................................................................ 106
..................................................................................................................................................................
EmptyTable 106
..................................................................................................................................................................
PrepareSQL 106
TCustomMyStoredProc
................................................................................................................................................................. 107
Description
............................................................................................................................................................ 107
Properties
............................................................................................................................................................ 107
..................................................................................................................................................................
StoredProcName 107
Methods
............................................................................................................................................................ 107
..................................................................................................................................................................
ExecProc 107
..................................................................................................................................................................
PrepareSQL 108
TMyBackup
................................................................................................................................................................. 109
Description
............................................................................................................................................................ 109
Properties
............................................................................................................................................................ 109
..................................................................................................................................................................
BackupPriority 109
..................................................................................................................................................................
Connection 110
..................................................................................................................................................................
Debug 110
..................................................................................................................................................................
Duplicates 110
..................................................................................................................................................................
EnclosedBy 110
..................................................................................................................................................................
EscapedBy 111
..................................................................................................................................................................
Fields 111
..................................................................................................................................................................
FieldsTerminatedBy 111
..................................................................................................................................................................
IgnoreLines 112
..................................................................................................................................................................
LinesTerminatedBy 112
..................................................................................................................................................................
Local 112
..................................................................................................................................................................
Mode 112
..................................................................................................................................................................
Path 113
..................................................................................................................................................................
TableNames 113
Methods
............................................................................................................................................................ 113
..................................................................................................................................................................
Backup 113
..................................................................................................................................................................
Restore 114
Events
............................................................................................................................................................ 114
..................................................................................................................................................................
OnTableMsg 114
TMyConnectDialog
................................................................................................................................................................. 115

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Contents VIII

Description
............................................................................................................................................................ 115
Properties
............................................................................................................................................................ 115
..................................................................................................................................................................
Connection 115
..................................................................................................................................................................
DatabaseLabel 115
..................................................................................................................................................................
PortLabel 115
..................................................................................................................................................................
ShowDatabase 116
..................................................................................................................................................................
ShowPort 116
TMyCommand
................................................................................................................................................................. 117
Description
............................................................................................................................................................ 117
Properties
............................................................................................................................................................ 117
..................................................................................................................................................................
CommandTimeout 117
..................................................................................................................................................................
Connection 117
..................................................................................................................................................................
InsertId 117
TMyConnection
................................................................................................................................................................. 119
Description
............................................................................................................................................................ 119
Properties
............................................................................................................................................................ 119
..................................................................................................................................................................
Charset 119
..................................................................................................................................................................
ClientVersion 119
..................................................................................................................................................................
ConnectionTimeout 119
..................................................................................................................................................................
IsolationLevel 120
..................................................................................................................................................................
Database 120
..................................................................................................................................................................
Options 121
..................................................................................................................................................................
Port 122
..................................................................................................................................................................
ServerVersion 122
Methods
............................................................................................................................................................ 123
..................................................................................................................................................................
CreateDataSet 123
..................................................................................................................................................................
CreateCommand 123
..................................................................................................................................................................
GetExecuteInfo 123
..................................................................................................................................................................
ExecSQL 123
..................................................................................................................................................................
Ping 124
TMyDump
................................................................................................................................................................. 125
Description
............................................................................................................................................................ 125
Properties
............................................................................................................................................................ 125
..................................................................................................................................................................
Connection 125
..................................................................................................................................................................
Debug 125
..................................................................................................................................................................
Objects 126
..................................................................................................................................................................
Options 126
..................................................................................................................................................................
SQL 127
..................................................................................................................................................................
TableNames 127
Methods
............................................................................................................................................................ 127
..................................................................................................................................................................
Backup 127
..................................................................................................................................................................
BackupQuery 128
..................................................................................................................................................................
Restore 129
Events
............................................................................................................................................................ 129
..................................................................................................................................................................
OnBackupProgress 129
..................................................................................................................................................................
OnRestoreProgress 129
TMyQuery
................................................................................................................................................................. 130
Description
............................................................................................................................................................ 130
Properties
............................................................................................................................................................ 130
..................................................................................................................................................................
UpdatingTable 130
TMyLoader
................................................................................................................................................................. 132
Description
............................................................................................................................................................ 132
MySQL Data Access Components, Copyright © 1998-2003 Core Lab

VIII
IX MySQL Data Access Components

Methods
............................................................................................................................................................ 132
..................................................................................................................................................................
Finish 132
Properties
............................................................................................................................................................ 132
..................................................................................................................................................................
Connection 132
..................................................................................................................................................................
Options 133
..................................................................................................................................................................
RowsPerQuery 133
TMyScript
................................................................................................................................................................. 134
Description
............................................................................................................................................................ 134
Properties
............................................................................................................................................................ 134
..................................................................................................................................................................
Connection 134
..................................................................................................................................................................
DataSet 134
..................................................................................................................................................................
Debug 134
..................................................................................................................................................................
Macros 135
..................................................................................................................................................................
SQL 135
Methods
............................................................................................................................................................ 135
..................................................................................................................................................................
ErrorOffset 135
..................................................................................................................................................................
Execute 136
..................................................................................................................................................................
FindMacro 136
..................................................................................................................................................................
MacroByName 136
Events
............................................................................................................................................................ 136
..................................................................................................................................................................
BeforeExecute 136
..................................................................................................................................................................
OnError 137
TMyStoredProc
................................................................................................................................................................. 138
Description
............................................................................................................................................................ 138
TMySQLMonitor
................................................................................................................................................................. 139
Description
............................................................................................................................................................ 139
TMyTable
................................................................................................................................................................. 140
Description
............................................................................................................................................................ 140
TMyServerControl
................................................................................................................................................................. 141
Description
............................................................................................................................................................ 141
Properties
............................................................................................................................................................ 141
..................................................................................................................................................................
Connection 141
..................................................................................................................................................................
Debug 141
..................................................................................................................................................................
TableNames 142
Methods
............................................................................................................................................................ 142
..................................................................................................................................................................
AnalyzeTable 142
..................................................................................................................................................................
CheckTable 142
..................................................................................................................................................................
CreateDatabase 143
..................................................................................................................................................................
DropDatabase 143
..................................................................................................................................................................
Flush 143
..................................................................................................................................................................
KillProcess 143
..................................................................................................................................................................
OptimizeTable 144
..................................................................................................................................................................
RepairTable 144
..................................................................................................................................................................
ShowProcessList 144
..................................................................................................................................................................
ShowVariables 144
..................................................................................................................................................................
ShowStatus 145
TMyUpdateSQL
................................................................................................................................................................. 146
Description
............................................................................................................................................................ 146
.....................................................................................................................................................................147
MyDAC Object and Component Listing by Unit
DALoader
................................................................................................................................................................. 147

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Contents X

Classes
............................................................................................................................................................ 147
DBAccess
................................................................................................................................................................. 148
Overview
............................................................................................................................................................ 148
Classes
............................................................................................................................................................ 148
MemData
................................................................................................................................................................. 149
Classes
............................................................................................................................................................ 149
MemDS
................................................................................................................................................................. 150
Classes
............................................................................................................................................................ 150
MydacVcl/MydacClx
................................................................................................................................................................. 151
Classes
............................................................................................................................................................ 151
MyAccess
................................................................................................................................................................. 152
Overview
............................................................................................................................................................ 152
Classes
............................................................................................................................................................ 152
MyBackup
................................................................................................................................................................. 153
Classes
............................................................................................................................................................ 153
MyLoader
................................................................................................................................................................. 154
Classes
............................................................................................................................................................ 154
MyDump
................................................................................................................................................................. 155
Classes
............................................................................................................................................................ 155
MySqlApi
................................................................................................................................................................. 156
Overview
............................................................................................................................................................ 156
MyScript
................................................................................................................................................................. 157
Classes............................................................................................................................................................ 157
VirtualTable
................................................................................................................................................................. 158
Classes
............................................................................................................................................................ 158

MySQL Data Access Components, Copyright © 1998-2003 Core Lab

X
11 MySQL Data Access Components

MySQL Data Access Components

1 Overview

MySQL Data Access Components (MyDAC) library offers a set of nonvisual components for Borland
Delphi, C++ Builder and Kylix. They provide access to MySQL database and are an alternative to a
standard way of accessing databases using Borland Database Engine (BDE) or dbExpress.

MyDAC can work using MySQL client or native MySQL network protocol. In case of using MySQL
protocol directly with DirectMySQLObjects by Cristian Nicola MyDAC doesn't require client library and
requires only TCP/IP protocol. This feature allows to build really thin database application.

Using BDE or dbExpress in MySQL oriented client/server applications has some deficiencies. In many
cases BDE and dbExpress community are unable to employ server specific features. Also BDE must
tolerate excessive usage of resources, reduced speed of processing data, restricted distribution of an
application and its administration.

Using BDE in database applications amounts to the following data path between server and client:

[MySQL] <-> [ODBC] <-> [BDE] <-> [Application]

MyDAC works directly through native MySQL interface.


It allows to avoid using BDE and ODBC:

[MySQL] <-> [Client library] <-> [Application]

Using MySQL network protocol provides optimal transfer way:

[MySQL] <-> [Application]

Key features

Following list describes the main features of MySQL Data Access Components:

· Direct access to MySQL data. No distributing, installing and configuring the BDE and ODBC;
· Doesn't require MySQL's software on client side with Direct option and works directly through
TCP/IP;
· Supports MySQL specific features;
· High performance controlled fetch of large data blocks;
· Optimized string and binary data storing;
· Automatic data updating with TMyQuery and TMyTable components;
· Automatic record refreshing;
· MySQL Embedded server support;
· Limited MySQL server 4.1 support;
· Separated run-time and GUI specific parts allow to create pure console applications such as CGI;
· Advanced design-time editors;
· MySQLBuilder Add-in extends design-time capabilities by set of tools to build and check queries;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 12

· Extended SQL tracing capabilities provided by TMySQLMonitor component and DBMonitor


application;
· Wide data-aware and reporting components support;
· Easy migration from BDE;
· Allows to use Professional Edition of Delphi, C++ Builder or Kylix to develop client/server
applications.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


13 MySQL Data Access Components

2 Compatibility

MyDAC is tested with MySQL server version 5.0, 4.1, 4.0 and 3.23.
Following IDE are supported by MyDAC: Borland Delphi 8, 7, 6 and 5, C++ Builder 6
and 5, Kylix 3 and 2. Only Professional and Enterprise editions are supported.
MyDAC does not support Kylix Open Edition.

If MyDAC works not using native protocol, MySQL client library is required. This is libmysql.dll file for
Windows, or libmysqlclient.so (libmysqlclient.so.X) for Linux. Please refer to descriptions of
LoadLibrary() and dlopen() functions accordingly for detailed information about MySQL client library file
location.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 14

3 Components

The components of MySQL Data Access Components library.

TMyConnection Establishes and controls connection to MySQL database server.

TMyQuery Uses SQL statements to retrieve data from MySQL table or tables
and supply it to one or more data-aware components through
TDataSource component. Provides flexible update of data.

TMyCommand Executes SQL statements, which do not return rowsets.

TMyTable Allows to retrieve and update data from a single table without
writing SQL statements.

TMyStoredProc Executes stored procedures and functions.

TMyScript Executes sequences of SQL statements.

TMyLoader Provides quick loading data to MySQL database.

TMyServerControl Serves to control the server and execution of standard service


tasks.

TMyDump Serves to store a database or its parts as a script and also to


restore database from received script.

TMyBackup Serves for backup copying specified tables on the server.

TMySQLMonitor Allows to monitor dynamic SQL requests in MyDAC based


applications.

TMyConnectDialog Is used on client side to supply username, password and server


name.

TVirtualTable Dataset that stores data in memory.

MyDataAdapter .NET component, uses TDataSet as data source for retrieving and
saving data to System.Data.DataSet

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


15 MySQL Data Access Components

4 Demos

Demos directory holds sample programs that demonstrate distinct features of MyDAC components.

AspNet - demonstrates ASP .NET application using MyDataAdapter;


CachedUpdates - working with cached updates and transaction control;
CBuilder - using MyDAC components with C++Builder;
Command - using TMyCommand;
ConnectDialog - customizing login dialog;
CRDBGrid - using TCRDBGrid component;
DLL - using MyDAC in DLLs;
Embedded - using MyDAC with MySQL Embedded server;
FastReport - additional components and demo project showing integration of MyDAC with
FastReport components;
InfoPower - additional components and demo project showing integration of MyDAC with
InfoPower components;
Loader - using TMyLoader;
MasterDetail - master/detail relationship;
MIDAS - using MIDAS technology with MyDAC;
Pictures - working with BLOB fields;
Query - using TMyQuery component;
QuickReport - using QuickReport with MyDAC;
ReportBuilder - using MyDAC with Report Builder components;
Table - using TMyTable;
Text - working with long string fields;
Transactions - working with transaction control;
UpdateSQL - using TMyUpdateSQL.
WinForms - using Windows Forms and MyDataAdapter component.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 16

5 Hierarchy chart

TObject
|— TPersistent
|— TComponent
|— TCustomConnection
| |— TCustomDAConnection
| |— TMyConnection
|— TDataSet
| |— TMemDataSet
| |— TCustomDADataSet
| | |— TCustomMyDataSet
| | |— TMyQuery
| | |— TCustomMyTable
| | | |— TMyTable
| | |— TCustomMyStoredProc
| | | |— TMyStoredProc
| | |— TMyServerControl
| |— TVirtualTable
|— TCustomDASQL
| |— TMyCommand
|— TMyBackup
|— TMyDump
|— TDALoader
| |— TMyLoader
|— TMyScript
|— TCustomDASQLMonitor
| |— TMySQLMonitor
|— TCustomConnectDialog
|— TMyConnectDialog
|— DADataAdapter
|— MyDataAdapter

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


17 MySQL Data Access Components

6 Writing GUI applications with MyDAC

NyDAC GUI part is standalone. This means that to make available GUI elements such as connect
form, connect dialog etc. you should explicitly include MydacVcl (MydacClx under Linux) unit to your
application. This feature is needed for writing console applications especially under Linux.

Delphi and C++Builder

By default MyDAC does not require Forms, Controls and another GUI related units. Only
TMyConnectDialog component require Forms unit according to their needs.

Kylix

By default MyDAC does not require QT library. Only TMyConnectDialog component include QT-
dependant code.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 18

7 Installation

MyDAC installer copies these files to folders where they should be resided.

The following packages are used with Delphi 5, Delphi 6, Delphi 7, C++ Builder 5, C++ Builder 6
projects:
dacXX.bpl - DAC run-time package (located in Windows\System folder)
dcldacXX.bpl - DAC design-time package (located in Delphi\Bin folder)
dacvclXX.bpl - DAC VCL support package (located in Delphi\Bin folder)
mydacXX.bpl - MyDAC run-time package (located in Windows\System folder)
dclmydacXX.bpl - MyDAC design-time package (located in Delphi\Bin folder)
mydacvclXX.bpl - VCL support package (located in Delphi\Bin folder)
crcontrolsXX.bpl - TCRDBGrid component (located in Delphi\Bin folder)

The following packages are used with Delphi 8 projects:


CoreLab.Dac.dll - DAC run-time package (located in Global Assembly Cache)
CoreLab.Dac.Design.dll - DAC design-time package
CoreLab.Mydac.dll - MyDAC Delphi 8 run-time package (located in Global Assembly Cache)
CoreLab.Mydac.Design.dll - MyDAC design-time package
CoreLab.Vcl.dll - TCRDBGrid component

Delphi

To compile MyDAC based application add $(DELPHI)\MyDAC\Lib to Project Options|Search path.

Delphi 8

To compile MyDAC based application add CoreLab.Dac and CoreLab.Mydac to Namespace prefixes.

C++ Builder

To compile MyDAC based application add $(BCB)\MyDAC\Lib to


Project Options|Library path and $(BCB)\MyDAC\Include to
Project Options|Include path.

Kylix

At first it is required to get MyDAC packages reachable for Kylix IDE. To do it you should add directory
where MyDAC packages are installed to LD_LIBRARY_PATH using following command

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<MyDAC directory>

Another way is to copy all MyDAC packages (*.so) to any reachable directory, for example kylix/bin.

Now you can install MyDAC in Kylix IDE. Please select Component/Install Packages from Kylix menu.
Press Add button and select bpldclmydacX.so.X.XX package. On pressing OK button components are
available in MySQL Access group. Also you should add odac/lib directory to Search Path of your
project.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


19 MySQL Data Access Components

8 Trial version restrictions

Note following restrictions when using MyDAC trial version:


· you can use MyDAC during 60 days starting from the moment of installation.
· MyDAC Trial version needs additional "bpl" files to be present on the user PC
If you build your project without run-time packages you nead:
dacXX.bpl
mydacXX.bpl

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 20

9 Using MyDAC

9.1 Migration from BDE

On MyDAC developing BDE users interests were taken in consideration so conversion from using BDE
into MyDAC can be passed without difficulties even for complex projects. Moreover, MyDAC does not
have problems appropriated BDE with LiveQuery and compatibility of different programs which were
developed using different BDE version and so on.

Refuse from using BDE gives one more important advantage - affect on performance. Instead of
complex BDE - ODBC drivers system it is used the fastest access way - direct to MySQL server. Also
access to MySQL Embedded server is supported.

MyDAC provides special Wizard to simplify conversion of already existent projects. This wizard
replaces BDE-components at the specified project (dfm-and pas-files) to MyDAC. BDE-components to
be replaced:

· TDatabase -> TMyConnection


· TQuery -> TMyQuery
· TTable -> TMyTable
· TUpdateSQL -> TMyUpdateSQL

To run wizard call from "MySQL" menu "BDE Migration Wizard" menu item and follow the instructions.

Note: wizard serves only to simplify routine operations and after the conversion project might be
uncompiled.

Below a list of properties and methods which cannot be converted automatically. Here you can find
hints for users to simplify manual replacement.

TDatabase
· AliasName - BDE-specific property. Not supported by MyDAC
· DatabaseName - has a different sense in BDE and MyDAC. At MyDAC it is understood as
MySQL Server database. See TMyConnection.Database for details
· Locale - see TMyConnection.CharSet
· KeepConnection - not supported by MyDAC
· Params - see TMyConnection properties
· Session, SessionAlias, SessionName - MyDAC does not need global management of a
group of database connections in an application. So these properties are not supported
· Temporary - has no sense in MyDAC. Additional connections are created but not available
for the user. See TCustomDADataSet.FetchAll = False for details
· TraceFlags - see TCustomDASQLMonitor.TraceFlags
· TransIsolation - see IsolationLevel
· Execute - use ExecSQL(SQL, [Null]) instead of this method
· FlushSchemaCache - not supported by MyDAC
· GetFieldNames - not supported by MyDAC
· IsSQLBased - not supported by MyDAC. For MySQL must be always True
· ApplyUpdates - parameters are not supported. To update only specified DataSets use

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


21 MySQL Data Access Components

TMemDataset.ApplyUpdates. Update is performed within a transaction.

TBDEDataSet
· BlockReadSize - see TCustomDADataSet.FetchRows
· CacheBlobs - MySQL Server does not provide service of suspended BLOB loading
· KeySize - BDE-specific property. Not supported by MyDAC.

TDBDataSet
· AutoRefresh - supported through TCustomDADataSet.RefreshOptions
· DBFlags, DBHandle, DBLocate, DBSession, Handle - BDE-specific property. Not supported by
MyDAC
· SessionName - not supported by MyDAC
· UpdateMode - not supported by MyDAC. By default, the behaviour corresponds
upWhereKeyOnly. To change this behaviour see TCustomDADataSet.SQLUpdate,
TCustomDADataSet.SQLDelete, TCustomDADataSet.SQLRefresh, and
TCustomMyDataSet.Options.CheckRowVersion.

TQuery
· Constrained - BDE-specific property. Not supported by MyDAC
· DataSource - see TCustomDADataSet.MasterSource
· Local - BDE-specific property. Not supported by MyDAC
· RequestLive - almost all query result sets are updatable. See TMyQuery.UpdatingTable,
TCustomDADataSet.ReadOnly, CanModify, TCustomDADataSet.SQLInsert,
TCustomDADataSet.SQLUpdate, TCustomDADataSet.SQLDelete.
· Text - BDE-specific property. Not supported by MyDAC.

TTable
· DefaultIndex - not used in MyDAC. If you need to sort a table by any field see
TCustomMyTable.OrderFields, TMemDataSet.IndexFieldNames
· Exists, CreateTable, AddIndex, DeleteIndex, StoreDefs, Deletetable, TableType - MyDAC
does not allow to create tables by using TTable. If you need to create a table execute 'CREATE
TABLE ...' query or use any special third-party tools.
· IndexDefs - not used in MyDAC, but fills on first call
· IndexFieldNames - a list of fields for local sorting. See TMemDataSet.IndexFieldNames
· IndexFieldCount, IndexFields, IndexFiles, IndexName, GetIndexNames, GetIndexInfo - Not
supported by MyDAC
· KeyExclusive - not supported by MyDAC. Use SELECT ... FROM .. WHERE ... to get
requested result
· KeyFieldCount - not supported by MyDAC as key fields are not used for searching on client
side
· TableLevel - BDE-specific property. Not supported by MyDAC
· ApplyRange, CancelRange, EditRangeStart, EditRangeEnd, SetRange - MyDAC does not
support Range
· BatchMove - has no sense in MySQL. Use INSERT ... INTO ... SELECT syntax to copy
records onto server side
· FindKey, FindNearest, GotoCurrent, GotoKey, GotoNearest, EditKey, SetKey - use
TMemDataSet.Locate and TMemDataSet.LocateEx
· GetDetailLinkFields - use TCustomDADataSet.DetailFields, TCustomDADataSet.MasterFields
· RenameTable - use 'RENAME TABLE ...' script
· ConstraintCallBack, ConstraintsDisabled, DisableConstraints, EnableConstraints - has no
sense in MySQL
· FlushBuffers - see TMyServerControl.Flush
· Translate - use AnsiToNative and so on functions.

TSession

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 22

MyDAC does not need global management of a group of database connections in an application.

TUpdateSQL
A complete analog to TMyUpdateSQL.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


23 MySQL Data Access Components

9.2 Working with master/detail relationships

Master/detail (MD) relationship between two tables is a very widespread one. So it is very important to
provide easy way for database application developer to work with it. Lets examine how MyDAC
implements this feature.
Suppose we have classic MD relationship between "Region" and "Territories" tables.
"Region" table has two following fields: RegionID and RegionDescription, where is RegionID is a
primary key.
"Territories" table has following fields: TerritoryID, TerritoryDescription and RegionID. TerritoryID is a
primary key and RegionID is a foreign key that binds "Region" to "Territories".
It is necessary to display and edit this tables.
MyDAC provides two ways to bind tables. First code example shows how to bind two
TCustomMyDataSet components (TMyQuery or TMyTable) into MD relationship via parameters.

procedure TForm1.Form1Create(Sender: TObject);


var
Master, Detail: TMyQuery;
MasterSource: TDataSource;
begin
...

// create master dataset


Master := TMyQuery.Create(Self);
Master.SQL.Text := 'SELECT * FROM Region';
Master.Connection := MyConnection;

// create detail dataset


Detail := TMyQuery.Create(Self);
Detail.SQL.Text := 'SELECT * FROM Territories WHERE RegionID =
:RegionID';
Detail.Connection := MyConnection;

// connect detail dataset with master via TDataSource component


MasterSource := TDataSource.Create(Self);
MasterSource.DataSet := Master;
Detail.MasterSource := MasterSource;

// open master dataset and only then detail dataset


Master.Open;
Detail.Open;

...
end;

Pay attention to one thing: parameter name in detail dataset SQL must be equal to field name in
master dataset that is used as foreign key for detail table. After opening detail dataset always holds
records with RegionID field value equal to one in current master dataset record.
There is an additional feature: when inserting new records to detail dataset it automatically fills foreign
key fields with values taken from master dataset.
Now suppose that detail table "Region" foreign key field is named RegionLink but not RegionID. In
such case detail dataset described in above code example will not autofill RegionLink field with current
"Region".RegionID value on insert. This issue is solved in second code example.

procedure TForm1.Form1Create(Sender: TObject);


var

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 24

Master, Detail: TMyQuery;


MasterSource: TDataSource;
begin
...

// create master dataset


Master := TMyQuery.Create(Self);
Master.SQL.Text := 'SELECT * FROM Region';
Master.Connection := MyConnection;

// create detail dataset


Detail := TMyQuery.Create(Self);
Detail.SQL.Text := 'SELECT * FROM Territories';
Detail.Connection := MyConnection;

// setup MD
Detail.MasterFields := 'RegionID'; // primary key in Region
Detail.DetailFields := 'RegionLink'; // foreign key in Territories

// connect detail dataset with master via TDataSource component


MasterSource := TDataSource.Create(Self);
MasterSource.DataSet := Master;
Detail.MasterSource := MasterSource;

// open master dataset and only then detail dataset


Master.Open;
Detail.Open;

...
end;

In this code example MD relationship is set up using MasterFields and DetailFields properties. Also
note that there are no WHERE clause in detail dataset SQL.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


25 MySQL Data Access Components

9.3 Using DBMonitor

To extend monitoring capabilities of MyDAC applications there is an additional tool called DBMonitor. It
is provided as an alternative to Borland SQL Monitor which is also supported by MyDAC.

DBMonitor is easy-to-use tool to provide visual monitoring of your database applications.


DBMonitor has following features:
· multiple client processes tracing;
· SQL event filtering (by sender objects);
· SQL parameter and error tracing.

DBMonitor is intended to hamper application being monitored as less as possible.

To trace your application with DBMonitor you should follow these steps:
· drop TMySQLMonitor component onto the form;
· turn moDBMonitor option on;
· set to True Debug property for components you want to trace;
· start DBMonitor before running your program.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 26

9.4 Secure connections

Session security depends on several factors, including whether the


connection you are using to the host is a trusted connection. If it is not,
consider whether private or confidential information will be sent and
received.

Encrypted connections in MySQL are achieved through the port forwarding with
Secure Shell Protocols (SSH).
Port forwarding is a powerful tool that allows you to secure TCP/IP traffic.

MyDAC allows to use such encrypted connections in your applications.


To setup connection with SSH you need:
· Install and configure SSH server such as OpenSSH from www.openssh.com
· Install SSH client;
· Set connection with port forwarding.

If you use OpenSSH client you should execute following command:


ssh.exe -L 3306:<YourMySQLServer name or IP>:3306 <YourSSHServer name or IP>;
Now your connection to localhost:3306 used by MyDAC is encrypted.
Security Considerations with Port Forwarding

It is important to understand that the client data is only encrypted between


the machine that SSH client is running on and the SSH server that SSH client
is connected to. Any data moving from the SSH server across the network to
another server is not encrypted.
To get more detailed information about using encrypted connections refer to
MySQL manual -> Connecting to a Remote MySQL from Windows with SSH topic.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


27 MySQL Data Access Components

9.5 Using Embedded server

Since version 4.0 MySQL server supports Embedded server. Embedded server is an easy at
installation server to be used by applications that do not require multi-user work with MySQL server. As
an example Embedded server can be used for money access machines, automatic cash desks,
different electronic facilities and so on. Please refer to MySQL Reference Manual for more details
about features and using of Embedded server. Also you can find an information about licensing
Embedded server at MySQL Reference Manual. Please refer to Embedded Demo to sample.

Windows
To install application that uses Embedded server at the end-user machine you should:
· Copy libmysqld.dll file to the folder available for executable file of the application. Please see
detailed description of accessible paths at LoadLibrary description;
· Create my.ini file at the root Windows folder and fill its following sections:

[Server] - common settings for MySQL usual and Embedded servers.


[Embedded] - settings specific to Embedded server.
[<Application exe-file name (with exstension)>] - settings specific to particular application.

Details about list of settings you can find at MySQL Reference Manual.

· Create folder to store data (by default, c:\mysql\data) and specify path to this folder at my.ini:

datadir=c:\mysql\data

or

datadir=.

At the last case files with data will be stored at the folder with your executable program.

Linux
· Copy libmysqld.so.14.0.0 file to /usr/lib folder
· At /usr/lib folder execute following commands to create links:
ln libmysqld.so.14.0.0 libmysqld.so
ln libmysqld.so.14.0.0 libmysqld.so.14

· - Create my.cnf file at /etc folder and fill its following sections:
[Server] - common settings for MySQL usual and Embedded servers.
[Embedded] - settings specific to Embedded server.
[<Application exe-file name (with exstension)>] - settings specific to particular application.
Details about list of settings you can find at MySQL Reference Manual.

· Create folder to store data (by default, /var/lib/mysql) and specify path to this folder at my.cnf:

datadir=c:\mysql\data

or

datadir=.

At the last case files with data will be stored at the folder with your executable program.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 28

Limitations
Simultaneous access to the same data from several instances of MySQL server (for example, to
MySQL server and Embedded server) can be a reason of data loss.

See Also
TMyConnection.Options.Embedded

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


29 MySQL Data Access Components

9.6 Using MyBuilder Add-in

To extend MyDAC design-time capabilities there is an MyBuilder Add-in provided. It is an easy to use
and versatile MyDAC design-time extension to manipulate data and database objects of MySQL. With
MyBuilder Add-in you can build, execute, verify and optimize your SQL statements.

MyBuilder Add-in are embedded in IDE and can be called from it's main menu, component editors and
component popup menus.

Sometimes when you install or upgrade MyBuilder Add-in or upgrade MyDAC there is an error
message during MyDAC design-time packages initialization. It says: 'Current version of MyBuilder Add-
in is incompatible with MyDAC X.XX'. To solve this problem go to MyBuilder Add-in directory and view
Requirements section in ReadMe.txt. You will find there lowest MyDAC version compatible with current
add-in version. Now if your current MyDAC version number is lower than required by add-in you should
upgrade MyDAC and if current version is higher then upgrade MyBuilder Add-in. In more rare cases
you may need to upgrade both products.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 30

10 MyDAC Alphabetical Object and Component


Listing

10.1 EDAError

10.1.1 Description

Unit
DBAccess

Description
EDAError is the base class for exceptions that are reaised when server side error occurs.

10.1.2 Properties
10.1.2.1 EDAError.ErrorCode

property ErrorCode: Integer

Description
Use ErrorCode to determine the error code returned by SQL server.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


31 MySQL Data Access Components

10.2 TDAColumn

10.2.1 Description

Unit
DALoader

Description
Each TDALoader uses TDAColumns to maintain a collection of TDAColumn objects. TDAColumn
object represents the attributes for column loading. Every TDAColumn object corresponds to one of
the table fields with the same name as its Name property.
To create columns at design-time use column editor of TDALoader component.

See Also
TDALoader
TDAColumns

10.2.2 Properties
10.2.2.1 TDAColumn.DataType

type
TDAColumnDataType = (ctString, ctDate, ctInteger, ctUInteger, ctFloat);

property DataType: TDAColumnDataType;

Description
Use DataType to specify types of values which will be loaded. Data types for columns may not match
data types for the corresponding fields in the database table. TDALoader will cast data values to the
types of their fields.

See Also
Name

10.2.2.2 TDAColumn.Name

property Name: String;

Description
Each TDAColumn corresponds to one field of loading table. Use Name property to specify name of this
field.

See Also
DataType

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 32

10.3 TDAColumns

10.3.1 Description

Unit
DALoader

Description
Each TDAColumns holds a collection of TDAColumn objects. TDAColumns maintains an index of the
columns in its Items array. The Count property contains the number of columns in the collection. At
design-time, use the Columns editor to add, remove, or modify columns.

See Also
TDALoader
TDAColumn

10.3.2 Properties
10.3.2.1 TDAColumns.Items

property Item[Index: Integer]: TDAColumn;

Description
Use Items to access individual columns. The value of the Index parameter corresponds to the Index
property of TDAColumn.

See Also
TDAColumn

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


33 MySQL Data Access Components

10.4 TBlob

10.4.1 Description

Unit
MemData

Description
Object TBlob holds large object value for field and parameter dtBlob, dtMemo data types.

SeeAlso
TBlobField
TCustomDADataSet.GetBlob

10.4.2 Properties
10.4.2.1 TBlob.AsString

property AsString: String;

Description
Use AsString property to manipulate blob value as string.

See Also
Assign
AsWideString

10.4.2.2 TBlob.AsWideString

property AsWideString: WideString;

Description
Use AsWideString property to manipulate blob value as unicode string.

See Also
Assign
AsString

10.4.2.3 TBlob.Size

property Size: Cardinal;

Description
Use Size to find the size of TBlob value in bytes.

10.4.2.4 TBlob.IsUnicode

property IsUnicode: boolean;

Description

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 34

Set IsUnicode to true if you want TBlob store and process data in Unicode format.

Note
Changing this property raises exception if TBlob is not empty.

10.4.3 Methods
10.4.3.1 TBlob.Assign

procedure Assign(Source: TBlob);

Description
Use Assign method to set blob value from another TBlob object.

See Also
LoadFromStream
AsString
AsWideString

10.4.3.2 TBlob.Clear

procedure Clear;

Description
Use Clear to delete the current value in TBlob object.

10.4.3.3 TBlob.LoadFromFile

procedure LoadFromFile(const FileName: String);

Description
Use LoadFromFile to load the contents of a file into a TBlob object. Specify the name of the file to load
into the field as the value of the FileName parameter.

See Also
SaveToFile
TBlobField.LoadFromFile

10.4.3.4 TBlob.LoadFromSream

procedure LoadFromStream(Stream: TStream);

Description
Use LoadFromStream to copy the contents of a stream into the TBlob object. Specify the stream from
which the field's value is copied as the value of the Stream parameter.

See Also
SaveToStream
TBlobField.LoadFromStream

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


35 MySQL Data Access Components

10.4.3.5 TBlob.Read

function Read(Position: cardinal; Count: cardinal; Dest: pointer):


cardinal;

Description
Use Read method to acquire a raw sequence of bytes from the data stored in TBlob.
Position parameter is the starting point of byte sequence which lasts Count number of bytes. Dest
parameter is a pointer to memory area where to store the sequence.
If the sequence crosses object size limit, function will return byte count actually read.

See Also
Write

10.4.3.6 TBlob.SaveToFile

procedure SaveToFile(const FileName: String);

Description
Use SaveToFile to save the contents of the TBlob object to a file. Specify the name of the file as the
value of the FileName parameter.

See Also
LoadFromFile
TBlobField.SaveToFile

10.4.3.7 TBlob.SaveToStream

procedure SaveToStream(Stream: TStream);

Description

Use SaveToStream to copy the contents of a TBlob object to a stream. Specify the name of the stream
to which the field's value is saved as the value of the Stream parameter.

See Also
LoadFromStream
TBlobField.SaveToStream

10.4.3.8 TBlob.Truncate

procedure Truncate(NewSize: Cardinal);

Description
Discards all data in the TBlob from the current position.

10.4.3.9 TBlob.Write

procedure Write(Position: cardinal; Count: cardinal; Source: pointer);

Description

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 36

Use Write method to store a raw sequence of bytes into the TBlob object.
Position parameter is the starting point of byte sequence which lasts Count number of bytes. Source
parameter is a pointer to a source memory area.
If the value of Position parameter crosses current size limit of TBlob object, source data will be
appended to the object data.

See Also
Read

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


37 MySQL Data Access Components

10.5 TCustomConnectDialog

10.5.1 Description

Unit
DBAccess

Description
TCustomConnectDialog is a base for connect dialog components. It provides functionality to show
dialog box where user can edit username, password and server name before connecting database.
You can customize captions of buttons and labels by their properties.

10.5.2 Properties
10.5.2.1 TCustomConnectDialog.CancelButton

property CancelButton: string;

Description
Use CancelButton property to specify label for cancel button.

10.5.2.2 TCustomConnectDialog.Caption

property Caption: string;

Description
Use Caption to set caption of dialog box.

10.5.2.3 TCustomConnectDialog.ConnectButton

property ConnectButton: string;

Description
Use ConnectButton property to specify label for connect button.

10.5.2.4 TCustomConnectDialog.DialogClass

property DialogClass: string;

Description
Use DialogClass property to specify class of form that will be displayed to enter login information.
When this property is blank TCustomConnectDialog uses the default form - TConnectForm. You can
write own login form to enter login information and assign its class name to DialogClass property. Each
login form must have ConnectDialog: TCustomConnectDialog published property to access to session
information. For details see implementation of TConnectForm.

See Also

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 38

ConnectDialog demo
GetServerList

10.5.2.5 TCustomConnectDialog.LabelSet

type
TLabelSet =
(lsCustom,lsEnglish,lsFrench,lsGerman,lsItalian,lsPolish,
lsPortuguese,lsRussian,lsSpanish);

property LabelSet: TLabelSet;

Description
Use LabelSet to set language of captions of labels and buttons.

The default value is lsEnglish.

10.5.2.6 TCustomConnectDialog.PasswordLabel

property PasswordLabel: string;

Description
Use PasswordLabel property to specify prompt for password edit.

10.5.2.7 TCustomConnectDialog.Retries

property Retries: Word;

Description
Use Retries to determine a number of retries of failed connections.

10.5.2.8 TCustomConnectDialog.SavePassword

property SavePassword: Boolean;

Description
When True and Password property of session instance is filled in, ConnectDialog displays password in
asterisks.

10.5.2.9 TCustomConnectDialog.ServerLabel

property ServerLabel: string;

Description
Use ServerLabel property to specify prompt for server name edit.

10.5.2.10 TCustomConnectDialog.StoreLogInfo

property StoreLogInfo: Boolean;

Description

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


39 MySQL Data Access Components

StoreLogInfo property specifies whether to keep login information in system registry after connection
has been established using provided username, password and servername.
Set this property to True to store login information.

The default value is True.

10.5.2.11 TCustomConnectDialog.UsernameLabel

property UsernameLabel: string;

Description
Use UsernameLabel property to specify prompt for username edit.

10.5.3 Methods
10.5.3.1 TCustomConnectDialog.Execute

function Execute: Boolean;

Description
Displays the connect dialog and calls session's Connect method when the user clicks Connect button.
Returns True if connected. If the user clicks Cancel, Execute returns False.

In case of failed connection Execute offers to connect repeat Retries times.

10.5.3.2 TCustomConnectDialog.GetServerList

procedure GetServerList(List: TStrings);

Description
Call GetServerList method to retrieve a list of available server names. It is particularly relevant for
writing custom login form.

See Also
DialogClass

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 40

10.6 TCustomDAConnection

10.6.1 Description

Unit
DBAccess

Description
TCustomDAConnection is a base class for components that establish connection with database,
provide customised login support, and perform transaction control.
Do not create instances of TCustomDAConnection. To add a component that represents connection to
a source of data, use descendants of TCustomDAConnection class.

10.6.2 Properties
10.6.2.1 TCustomDAConnection.ConnectDialog

property ConnectDialog: TCustomConnectDialog;

Description
Use ConnectDialog property to assign to connection TCustomConnectDialog component.

See Also
TCustomConnectDialog
10.6.2.2 TCustomDAConnection.InTransaction

property InTransaction: Boolean

Description
Examine InTransaction property at runtime to determine whether user transaction is currently in
progress. In the other words InTransaction is set to True when user explicitly calls StartTransaction.
Calling Commit or Rollback sets InTransaction to False. The value of InTransaction property cannot be
changed directly.
See Also
StartTransaction
Commit
Rollback

10.6.2.3 TCustomDAConnection.Password

property Password: String;

Description
Use Password property to supply password to handle server's request for a login.

Warning: Storing hard-coded user name and password entries as property values or in code for an
OnLogin event handler can compromise server security.

See Also
Username

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


41 MySQL Data Access Components

Server
TCustomConnection.OnLogin

10.6.2.4 TCustomDAConnection.Pooling

property Pooling: boolean default False;

Description
Normally, when TCustomDAConnection establishes connection with the server it takes server memory
and time resources for allocation a new server session. If an application has wide user activity that
forces many connect/disconnect operations, it may spend a lot of time on creating connection and
sending requests to the server. TCustomDAConnection has software pool which stores open
connections with identical parameters.
Set Pooling to True to enable pooling. Specify correct values for PoolingOptions. Two connections
belong to the same pool if they have identical values for parameters: MinPoolSize, MaxPoolSize,
ConnectionLifeTime, Server, Username, Password, Database, IsolationLevel, Port, QuotedIdentifier,
ConnectionTimeout, Compress, Direct, Embedded, Protocol.

Note: Using Pooling := True can cause errors with working with temporary tables.

See Also
Username
Password
PoolingOptions

10.6.2.5 TCustomDAConnection.PoolingOptions

type
TPoolingOptions = class(TPersistent)
published
property MaxPoolSize: integer default 100;
property MinPoolSize: integer default 0;
property ConnectionLifetime: integer default 0;
end;

property PoolingOptions: TPoolingOptions;

Description
Set properties of PoolingOptions to specify behaviour of connection pool. The meaning of
PoolingOptions' properties are:

Property Meaning

MaxPoolSize Specifies the maximum number of connections that can be opened in the
connection pool. Once this value is reached, no more connection are opened.
The valid values are 1 and above.

MinPoolSize Specifies the minimum number of connections that can be opened in the
connection pool.

ConnectionLifetime Specifies the maximum time in which opened connection can be used by
connection pool. Pool deletes connections with exceeded connection lifetime

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 42

when TCustomDAConnection is about to close. If set ConnectionLifetime


property to 0 (by default), then life time of connection is infinity.

See Also
Pooling

10.6.2.6 TCustomDAConnection.Server

property Server: String;

Description
Use Server property to supply server name to handle server's request for a login.

Server property can be used only if Options.Embedded set to False.

See Also
Username
Password
Port
TCustomConnection.OnLogin

10.6.2.7 TCustomDAConnection.Username

property Username: String;

Description
Use Username property to supply user name to handle server's request for a login.

Warning: Storing hard-coded user name and password entries as property values or in code for an
OnLogin event handler can compromise server security.

See Also
Password
Server
TCustomConnection.OnLogin

10.6.3 Methods
10.6.3.1 TCustomDAConnection.ApplyUpdates

procedure ApplyUpdates;

Description
Call ApplyUpdates to write all pending cached updates from all active datasets attached to this

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


43 MySQL Data Access Components

connection to a database. ApplyUpdates method passes cached data to the database for storage,
takes care of committing or rolling back transactions and clearing the cache when the operation is
successful.
Using ApplyUpdates for connection is a prefered method of updating datasets rather than calling each
individual dataset's ApplyUpdates method.

See Also
TMemDataSet.CachedUpdates
TMemDataSet.ApplyUpdates

10.6.3.2 TCustomDAConnection.Commit

procedure Commit;

Description
Call Commit to commit current transaction. On commit server writes permanently all pending data
updates associated with the current transaction to the database and then ends the transaction. The
current transaction is the last transaction started by calling StartTransaction.

See Also
Rollback
StartTransaction
TCustomDADataSet.FetchAll
10.6.3.3 TCustomDAConnection.Connect

procedure Connect;

Description
Call Connect method to establish connection to a server. Connect sets the Connected property to
True. If LoginPrompt is True Connect prompts user for login information as required by the server, or
otherwise tries to establish connection using values, provided in Username, Password and Server
properties.

See Also
Disconnect
Username
Password
Server
ConnectDialog

10.6.3.4 TCustomDAConnection.CreateDataSet

function CreateDataSet: TCustomDADataSet;

Description
CreateDataSet returns a new instance of TCustomDADataSet class and associates it with this
connection object. In descendant classes this method should be overridden to create appropriate
descendant of TCustomDADataset component.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 44

10.6.3.5 TCustomDAConnection.CreateSQL

function CreateSQL: TCustomDASQL;

Description
CreateSQL returns a new instance of TCustomDASQL class and associates it with this connection
object. In descendant classes this method should be overridden to create appropriate descendant of
TCustomDASQL component.

10.6.3.6 TCustomDAConnection.Disconnect

procedure Disconnect;

Description
Call Disconnect to drop a connection to database. Before the connection component is deactivated, all
associated datasets are closed. Calling Disconnect is the same as setting the Connected property to
False.
In most cases, closing a connection frees system resources allocated to the connection.
If user transaction is active, i.e InTransaction flag is set, calling Disconnect commits current user
transaction.

Note: If a previously active connection is closed and then reopened, any associated datasets must be
individually reopened; reopening the connection does not automatically reopen associated datasets.

See also
TCustomConnection.Connected
Connect
10.6.3.7 TCustomDAConnection.ExecSQL

function ExecSQL(Text: string; const Params: array of variant): variant;

Description
Use ExecSQL method to execute any SQL statement outside of TCustomDADataSet or
TCustomDASQL components. Supply Params array with values of parameters arranged in the same
order as they appear in SQL statement which itselt is passed in Text string parameter.

Note: If a query doesn't have parameters (Params.Count = 0), this query will be executed faster.

See also
TMyConnection.ExecSQL

10.6.3.8 TCustomDAConnection.GetDatabaseNames

procedure GetDatabaseNames(List: TStrings);

Description
Populates a string list with the names of databases.

Note: Any contents already in the target string list object are eliminated and overwritten by the data
produces by GetDatabaseNames.

See Also

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


45 MySQL Data Access Components

GetTableNames
GetStoredProcNames
TMyConnection.Database

10.6.3.9 TCustomDAConnection.GetTableNames

procedure GetTableNames(List: TStrings);

Description
Populates a string list with the names of tables in the database.

Note: Any contents already in the target string list object are eliminated and overwritten by the data
produces by GetTableNames.

See Also
GetDatabaseNames
GetStoredProcNames

10.6.3.10 TCustomDAConnection.GetStoredProcNames

procedure GetStoredProcNames(List: TStrings);

Description
Populates a string list with the names of stored procs in the database.

Note: Any contents already in the target string list object are eliminated and overwritten by the data
produces by GetStoredProcNames.

See Also
GetDatabaseNames
GetTableNames

10.6.3.11 TCustomDAConnection.Rollback

procedure Rollback;

Description
Call Rollback to discard all updates, insertions, and deletions of data associated with the current
transaction to the database server and then end the transaction. The current transaction is the last
transaction started by calling StartTransaction.

See Also
Commit
StartTransaction
TCustomDADataSet.FetchAll

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 46

10.6.3.12 TCustomDAConnection.StartTransaction

procedure StartTransaction;

Description
Call StartTransaction to begin a new user transaction against the database server. Before calling
StartTransaction, an application should check the status of the InTransaction property. If InTransaction
is True, indicating that a transaction is already in progress, a subsequent call to StartTransaction
without first calling Commit or Rollback to end the current transaction raises EDatabaseError. Calling
StartTransaction when connection is closed also raises EDatabaseError.
Updates, insertions, and deletions that take place after a call to StartTransaction are held by the server
until an application calls Commit to save the changes or Rollback to cancel them.

See Also
Commit
Rollback
InTransaction
IsolationLevel

10.6.4 Events
10.6.4.1 TCustomDAConnection.OnError

Type
TDAConnectionErrorEvent = procedure (Sender: TObject; E: EDAError; var
Fail: boolean) of object;

property OnError: TDAConnectionErrorEvent;

Description
Write an OnError event handler to respond to errors that arise with connection. Check E parameter to
get an error code. Set the Fail parameter to False to prevent an error dialog from being displayed and
to raise EAbort exception to cancel current operation. The default value of Fail is True.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


47 MySQL Data Access Components

10.7 DADataAdapter

10.7.1 Description

Unit
CoreLab.Dac.DataAdapter

Description
DataAdapter serves as a bridge between a System.Data.DataSet and a TDataSet component (data
source) for retrieving and saving data. DataAdapter provides this bridge by mapping Fill, which
changes the data in the System.Data.DataSet to match the data in the data source, and Update, which
changes the data in the data source to match the data in the System.Data.DataSet.

See Also
MyDataAdapter

10.7.2 Properties
10.7.2.1 DADataAdapter.DataSet

property DataSet: TDataSet;

Description
Specify TDataSet object which will be used as data source for DADataAdapter component.

10.7.3 Methods
10.7.3.1 DADataAdapter.Fill

function Fill(Data: DataSet; tableName: string): integer;

Description
Adds or refreshes rows in the System.Data.DataSet to match those in the TDataSet using the DataSet
parameter, and creates a DataTable named tableName. Function returns the number of rows
successfully inserted to DataSet.

TDataSet object associated with DADataAdapter must be valid, but it does not need to be open. If
TDataSet is closed before Fill is called, it is opened to retrieve data, then closed. If TDataSet is open
before Fill is called, it remains open.

If an error is encountered while populating the dataset, rows added prior to the occurrence of the error
remain in the dataset. The remainder of the operation is aborted.

If TDataSet does not return any rows, fields are created and no rows are added to the DataSet, and no
exception is raised.

See Also
Update

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 48

10.7.3.2 DADataAdapter.Update

function Update(Data: DataSet; tableName: string): integer;

Description
Perform Insert, Edit, Delete for each inserted, updated, or deleted row in the specified
System.Data.DataSet due to the ordering of the rows in the DataTable. It should be noted that these
statements are not performed as a batch process; each row is updated individually. Function returns
the number of rows successfully updated from the DataSet.

See Also
Fill

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


49 MySQL Data Access Components

10.8 TCustomDADataSet

10.8.1 Description

Unit
DBAccess

Description
TCustomDADataSet encapsulates general set of properties, events, and methods for working with
data accessed through various database engines. All database-specific features are expressly
supported by descendants of TCustomDADataSet.
Applications should never use TCustomDADataSet objects directly.

10.8.2 Properties
10.8.2.1 TCustomDADataSet.AutoCommit

property AutoCommit: Boolean;

Description
When True and Session.AutoCommit is True and Session.InTransaction is False, each update, insert
or delete statement is automatically committed by database server.

10.8.2.2 TCustomDADataSet.BaseSQL

property BaseSQL: String;

Description
Use BaseSQL to return SQL text without any changes performed by AddWhere, SetOrderBy and
FilterSQL, only macros are expanded. SQL text with all these changes can be returned by FinalSQL.

See Also
FinalSQL
AddWhere

10.8.2.3 TCustomDADataSet.Connection

property Connection: TCustomDAConnection;

Description
Use Connection to specify a connection object to use to connect to a data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its descendant class
objects.
At runtime, set Connection property to reference an instanciated TCustomDAConnection object.

10.8.2.4 TCustomDADataSet.Debug

property Debug: Boolean;

Description

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 50

Set Debug to True to display executing statement and all its parameter values. Also displays type of
parameters.

Note: To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx
under Kylix) unit.

See also:
TCustomDASQL.Debug
10.8.2.5 TCustomDADataSet.DetailFields

property DetailFields: String;

Description
Use DetailFields property to specify fields that correspond to foregin key fields from MasterFields when
building master/detail relationship. DetailFields is a string containing one or more field names in the
detail table. Separate field names with semicolons.

Use Field Link Designer to set the value in design time.

See Also
MasterFields
MasterSource

10.8.2.6 TCustomDADataSet.FetchAll

property FetchAll: Boolean;

Description
Set FetchAll to True to request all records of the query from database server when the dataset is
opening. When set to False, records are retrieved when a data-aware component or a program
requests it. If a query can return a lot of records, set this property to False if initial response time is
important.

Setting FetchAll property to False causes that first call of Locate(LocateEx) method may takes a lot of
time to retrieve additional records on client side.

Default value is True.

Note:
When setting TCustomMyDataSet.FetchAll = False you should keep in mind that execution of such
queries blocks current session. In order to avoid blocking MyDAC creates additional session which
causes following problems:
· Each additional session runs outside of the transaction context thus TMyConnection.Commit and
TMyConnection.Rollback operations in main session won't apply changes made in additional
sessions.
· Temporary tables created in one session are not accessible from other sessions therefore
simultaneous using of FetchAll = False and temporary tables is impossible.
· Lock cannot be used
· LockTable cannot be used

See also:
TCustomDADataSet.FetchRows

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


51 MySQL Data Access Components

10.8.2.7 TCustomDADataSet.FetchRows

property FetchRows: Integer;

Description
Number of rows that will be transferred across the network at the same time. This property can have a
great impact on performance. So it is preferable to choose the optimal value of FetchRows property for
each SQL statement and software - hardware configuration experimentally.

The default value is 25.

10.8.2.8 TCustomDADataSet.FilterSQL

property FilterSQL: string;

Description
FilterSQL property is like Filter property but in a differ it changes WHERE clause SELECT statement
and reopens query. Syntax is the same to WHERE clause.

Example

Query1.FilterSQL := 'Dept >= 20 and DName LIKE ''M%''';

See Also
AddWhere

10.8.2.9 TCustomDADataSet.FinalSQL

property FinalSQL: String;

Description
Use FinalSQL to return SQL text with all the changes performed by AddWhere, SetOrderBy and
FilterSQL and with with expanded macros. This is exactly the statement which will be passed on to
database server.

See Also

10.8.2.10 TCustomDADataSet.IsQuery

property IsQuery: Boolean;

Description
After TCustomDADataSet component is prepared IsQuery property returns True if SQL statement is a
SELECT query.
Use IsQuery property to check whether SQL statement returns rows or not.
IsQuery is a read-only property. Reading IsQuery on unprepared dataset raises exception.

10.8.2.11 TCustomDADataSet.MacroCount

property MacroCount: Integer;

Description
Read MacroCount to get a number of macros associated with the Macros property.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 52

See Also
Macros

10.8.2.12 TCustomDADataSet.Macros

property Macros: TMacros;

Description
With the help of macros you can easily change SQL query text at design- or runtime. Marcos extend
abilities of parameters and allow to change conditions in WHERE clause or sort order in ORDER BY
clause. You just insert &MacroName in SQL query text and change value of macro in Macro property
editor at design time or call MacroByName function at run time. At the time of opening query macro is
replaced by its value.

Example

MyQuery.SQL := 'SELECT * FROM Dept ORDER BY &Order';


MyQuery.MacroByName('Order').Value := 'DeptNo';
MyQuery.Open;

See Also
TMacro
MacroByName
Params
10.8.2.13 TCustomDADataSet.MasterFields

property MasterFields: String;

Description
Use MasterFields after setting MasterSource property to specify the names of one or more fields that
are used as foreign keys for this dataset when establishing detail-master relationship between it and
the dataset specified in MasterSource.
MasterFields is a string containing one or more field names in the master table. Separate field names
with semicolons.
Each time the current record in the master table changes, the new values in those fields are used to
select corresponding records in this table for display.

Use Field Link Designer to set the values at design time after setting MasterSource property.

See Also
DetailFields
MasterSource
Working with master/detail relationships

10.8.2.14 TCustomDADataSet.MasterSource

property MasterSource: TDataSource;

Description
MasterSource property specifies the data source component which binds current dataset to master
one.
TCustomDADataset uses MasterSource property to extract foreign key fields values from master
dataset when building master/detail relationship between two datasets. MasterSource must point to
another dataset; it cannot point to this dataset component.
When MasterSource is not nil dataset fills parameter values with corresponding field values from

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


53 MySQL Data Access Components

current record of the master dataset.

Note: Do not set DataSource property when building master/detail relationships. Although it points to
the same object as MasterSource property, it may lead to undesirable results.

See Also
MasterFields
DetailFields
Working with master/detail relationships
10.8.2.15 TCustomDADataSet.Options

type
TDADataSetOptions = class (TPersistent)
published
property FlatBuffers: boolean;
property NumberRange: boolean;
property QueryRecCount: boolean;
property RemoveOnRefresh: boolean;
property RequiredFields: boolean;
property ReturnParams: boolean;
property StrictUpdate: boolean;
end;

property Options: TDADataSetOptions;

Description
Set properties of Options to specify behaviour of TCustomDADataSet object. The meanings of
Options' properties are:

Property Description

FlatBuffers Controls how dataset treats data of ftString and ftVarBytes fields. When set to
True all data fetched from server is stored in record buffers, increasing speed
of local operations with this fields. But if you need to fetch table with large
amount of string data you can significantly decrease memory usage by setting
this option to False. Because usually actual strings stored in database are less
than maximum field size. And by turning off FlatBuffers option you will make
dataset to allocate memory as much as needed to store actual data without
unused tails.

LongStrings Represents string fields with the length that is greater than 255 as TStrigField
not as TMemoField.

NumberRange Sets MaxValue and MinValue properties of TIntegerField and TFloatField to


appropriate values.

QueryRecCount If True TCustomDADataSet performes additional query to get record count for
this SELECT so RecordCount property reflects the actual number of records.

RemoveOnRefresh When RemoveOnRefresh is turned on dataset locally removes record on


refresh if it does not match filter condition (WHERE clause for refresh SQL)
anymore.

RequiredFields If True TCustomDADataSet sets Required property of TField objects for NOT
NULL fields. It useful when table has trigger which updates NOT NULL fields.

ReturnParams Returns new value of fields to dataset after insert or update. Actual value of

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 54

field after insert or update may be different from the value stored in local
memory if the table has a trigger. When ReturnParams is True OUT
parameters of SQLInsert and SQLUpdate statements is assigned to
corresponding fields.

StrictUpdate TCustomDADataSet raises exception when number of the updated or deleted


records does not equal to 1. Setting this option also causes an exception if
RefreshRecord procedure returns more than one record. The exception does
not occur when you use non-SQL block.

10.8.2.16 TCustomDADataSet.ParamCheck

property ParamCheck: boolean;

Description
Use ParamCheck to specify whether parameters for Params property are implicitly generated when
SQL property is changing.
Set ParamCheck to True to let dataset automatically generate Params property for dataset based on
SQL statement.
Setting ParamCheck to False is mainly suited if the dataset component passes to a server the DDL
statements that contain, for example, declarations of stored procedures which themselves will accept
parameterized values. Default value is True.

See Also
Params

10.8.2.17 TCustomDADataSet.ParamCount

property ParamCount: Integer;

Description
Use ParamCount to determine how many parameters are there in the Params property.

See Also
Params

10.8.2.18 TCustomDADataSet.Params

property Params: TDAParams;

Description
Contains the parameters for a query's SQL statement.
Access Params at runtime to view and set parameter names, values, and data types dynamically (at
design time use the Parameters editor to set parameter information). Params is a zero-based array of
parameter records. Index specifies the array element to access.
An easier way to set and retrieve parameter values when the name of each parameter is known is to
call ParamByName.

See Also
ParamByName
Macros

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


55 MySQL Data Access Components

10.8.2.19 TCustomDADataSet.ReadOnly

property ReadOnly: Boolean;

Description
Use ReadOnly to prevent users from updating, inserting, or deleting data in the dataset. By default,
ReadOnly is False, meaning users can potentially alter a dataset's data.
To guarantee that users cannot modify or add data to a dataset, set ReadOnly to True.
When ReadOnly is True, the dataset's CanModify property is False.

10.8.2.20 TCustomDADataSet.RefreshOptions

type
TRefreshOption = (roAfterInsert, roAfterUpdate, roBeforeEdit);
TRefreshOptions = set of TRefreshOption;

property RefreshOptions: TRefreshOptions;

Description
Use RefreshOptions property to determine when the editing record will be refreshed.
Refresh is performed by RefreshRecord method.
It queries current record and replaces one in dataset. Refresh record is useful when the table has
triggers or fields of the table have default values. Use roBeforeEdit to get actual data before editing.

Value Meaning

roAfterInsert Refresh is performed after insert a record


roAfterUpdate Refresh is performed after update a record
roBeforeEdit Refresh is performed by Edit method

The default value is [].

See Also
RefreshRecord

10.8.2.21 TCustomDADataSet.RowsAffected

property RowsAffected: Integer;

Description
Check RowsAffected to determine how many rows were updated or deleted during the last query
operation. If RowsAffected is -1, the query did not update or delete any rows.

10.8.2.22 TCustomDADataSet.SQL

property SQL: TStrings;

Description
Use SQL to provide the SQL statement that a query component executes when its Open method is
called. At design time the SQL property can be edited by invoking the String List editor in the Object
Inspector.
When SQL is changed TCustomDADataSet calls Close and UnPrepare.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 56

10.8.2.23 TCustomDADataSet.SQLDelete

property SQLDelete: TStrings;

Description
Use SQLDelete property to specify SQL statement that will be used when applying a deletion to a
record. Statements can be parameterized queries.
To create SQLDelete statement at design-time, use query statements editor.

Example

DELETE FROM Orders


WHERE
OrderID = :Old_OrderID

See Also
SQLInsert
SQLUpdate

10.8.2.24 TCustomDADataSet.SQLInsert

property SQLInsert: TStrings;

Description
Use SQLInsert property to specify SQL statement that will be used when applying an insertion to a
dataset. Statements can be parameterized queries. Names of the parameters should be the same as
field names. Parameters prefixed with OLD_ allow to use current values of fields prior to actual
operation.
To create SQLInsert statement at design-time, use query statements editor.

Example

INSERT INTO Orders


(Shipname)
VALUES
(:Shipname)

See Also
SQLUpdate
SQLDelete

10.8.2.25 TCustomDADataSet.SQLRefresh

property SQLRefresh: TStrings;

Description
Use SQLRefresh property to specify SQL statement that will be used to refresh current record by
calling RefreshRecord procedure.
Another behavior is observed when SQLRefresh property is assigned with a single WHERE clause that
holds frequently altered search condition. In this case WHERE clause from SQLRefresh is combined
with the same clause of SELECT statement in SQL property and this final query is then sent to
database server.
To create SQLRefresh statement at design-time, use query statements editor.

Example

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


57 MySQL Data Access Components

SELECT Shipname FROM Orders


WHERE
OrderID = :OrderID

See Also
RefreshRecord

10.8.2.26 TCustomDADataSet.SQLUpdate

property SQLUpdate: TStrings;

Description
Use SQLUpdate property to specify SQL statement that will be used when applying an update to a
dataset. Statements can be parameterized queries. Names of the parameters should be the same as
field names. Parameters prefixed with OLD_ allow to use current values of fields prior to actual
operation.
To create SQLUpdate statement at design-time, use query statement editor.

Example

UPDATE Orders
SET
ShipName = :ShipName,
WHERE
OrderID = :Old_OrderID

See Also
SQLInsert
SQLDelete

10.8.2.27 TCustomDADataSet.UniDirectional

property UniDirectional: Boolean;

Description
Traditionally SQL cursors are unidirectional. They can travel only forward through a dataset. The
TCustomDADataset, however, permits bidirectional travel by caching records. If an application does
not need bidirectional access to records in a result set, set UniDirectional to True. When UniDirectional
is True, an application requires less memory and performance is improved.
The default value of UniDirectional is False, enabling forward and backward navigation.

10.8.2.28 TCustomDADataSet.UpdateObject

property UpdateObject: TCustomDAUpdateSQL;

Description
UpdateObject property points to an update object component which provides SQL statements that
perform updates of read-only datasets when cached updates are enabled.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 58

10.8.3 Methods
10.8.3.1 TCustomDADataSet.AddWhere

procedure AddWhere(Condition: string);

Description
Call AddWhere to add condition to WHERE clause of SELECT statement in SQL property.
If SELECT statement has not WHERE clause AddWhere creates it.

Note: AddWhere method is implicitly called by RefreshRecord.

See Also
DeleteWhere

10.8.3.2 TCustomDADataSet.DeleteWhere

procedure DeleteWhere;

Description
Call DeleteWhere to remove WHERE clause from SQL property and assign BaseSQL property.

See Also
AddWhere
BaseSQL

10.8.3.3 TCustomDADataSet.Execute

procedure Execute;

Description
Use Execute to execute the SQL statement on the server. If SQL statement is a query Execute calls
Open method.
Execute implicitly prepares the SQL statement by calling Prepare method if it has not already been
prepared. To speed up performance, in case of multiple Execute calls an application should call
Prepare before calling Execute method for the first time.

See Also
AfterExecute
Executing
Prepare
10.8.3.4 TCustomDADataSet.Executing

function Executing: Boolean;

Description
Check Executing to learn whether TCustomDADataSet still executes SQL statement.

10.8.3.5 TCustomDADataSet.Fetched

function Fetched: Boolean;

Description
Check Fetched property to learn whether TCustomDADataSet has already fetched all rows or not.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


59 MySQL Data Access Components

See Also
Fetching

10.8.3.6 TCustomDADataSet.Fetching

function Fetching: Boolean;

Description
Check Fetching to learn whether TCustomDADataSet still fetching rows.

See Also
Executing

10.8.3.7 TCustomDADataSet.FetchingAll

function FetchingAll: Boolean;

Description
Check FetchingAll to learn whether TCustomDADataSet is fetching all rows to the end.

See Also
Executing

10.8.3.8 TCustomDADataSet.FindMacro

function FindMacro(Name: String): TMacro;

Description
Call FindMacro to determine if a specified macro exists in a dataset. Name is the name of the macro
for which to search. If FindMacro finds a macro with a matching name, it returns the TMacro object for
the specified Name. Otherwise it returns nil.

See Also
TMacro
Macros
MacroByName

10.8.3.9 TCustomDADataSet.FindParam

function FindParam(Name: String): TDAParam;

Description
Call FindParam to determine if a specified param component exists in a dataset. Name is the name of
the param for which to search. If FindParam finds a param with a matching name, it returns the
TDAParam object for the specified Name. Otherwise it returns nil.

See Also
Params
ParamByName

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 60

10.8.3.10 TCustomDADataSet.GetBlob

function GetBlob(const FieldName: String): TBlob;

Description
Call GetBlob to retrieve TBlob object for a field or current record when only its name is known.
FieldName is the name of an existing field. The field should have Memo or Blob type.

Example

MyQuery1.GetBlob('Comment').SaveToFile('Comment.txt');

See Also
TBlob
10.8.3.11 TCustomDADataSet.GetDataType

function GetDataType(const FieldName: String): Integer;

Description
Use GetDataType to return internal field types defined in MemData and accompanying modules.
Internal field data types extend TFieldType type of VCL by specific database server data types. For
example dtString, dtFile, dtObject.

10.8.3.12 TCustomDADataSet.GetFieldObject

function GetFieldObject(const FieldName: string): TSharedObject;

Description
Use GetFieldObject to return multireference shared object from dataset. If field does not hold one of
the TSharedObject descendants GetFieldObject raises an exception.

10.8.3.13 TCustomDADataSet.GetFieldPrecision

function GetFieldPrecision(const FieldName: String): Integer;

Description
Call GetFieldPrecision to retrieve precision of number field. FieldName is the name of an existing field.

See Also
GetFieldScale

10.8.3.14 TCustomDADataSet.GetFieldScale

function GetFieldScale(const FieldName: String): Integer;

Description
Call GetFieldScale to retrieve scale of number field. FieldName is the name of an existing field.

See Also
GetFieldPrecision

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


61 MySQL Data Access Components

10.8.3.15 TCustomDADataSet.GetOrderBy

function GetOrderBy: string;

Description
Call GetOrderBy method to retrieve ORDER BY clause from SQL statement.

Note: GetOrderBy and SetOrderBy methods serve to process only quite simple queries and don't
support, for example, subqueries.

See Also
SetOrderBy
10.8.3.16 TCustomDADataSet.MacroByName
Accesses macro information based on a specified macro name.

function MacroByName(Name: String): TMacro;

Description
Use MacroByName method to find a Macro with the name passed in Name. If a match is found,
MacroByName returns the Macro. Otherwise, an exception is raised. Use this method rather than a
direct reference to the Items property to avoid depending on the order of the entries.

To locate a parameter by name without raising an exception if the parameter is not found, use the
FindMacro method.

To assign value of macro use TMacro.Value property.

Example

MyQuery.SQL:= 'SELECT * FROM Scott.Dept ORDER BY &Order';


MyQuery.MacroByName('Order').Value:= 'DeptNo';
MyQuery.Refresh;

See Also
TMacro
Macros
FindMacro

10.8.3.17 TCustomDADataSet.ParamByName
Accesses parameter information based on a specified parameter name.

function ParamByName(Name: String): TDAParam;

Description
Call ParamByName to set or use parameter information for a specific parameter based on its name.
Name is the name of the parameter for which to retrieve information. ParamByName is used to set an
parameter's value at runtime and returns TDAParam object. For example, the following statement
retrieves the current value of a parameter called "Contact" into an edit box:

Example

Edit1.Text := Query1.ParamsByName('Contact').AsString;

See Also
Params
FindParam

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 62

10.8.3.18 TCustomDADataSet.Prepare

procedure Prepare;

Description

Method Prepare currently is not supported by MySQL.

See Also
Prepared
UnPrepare
10.8.3.19 TCustomDADataSet.RefreshRecord

procedure RefreshRecord;

Description
Use RefreshRecord to actualize field values for current record. RefreshRecord performes query to
database and refetches new vield values from returned cursor.

See Also
RefreshOptions

10.8.3.20 TCustomDADataSet.RestoreSQL

procedure RestoreSQL;

Description
Use RestoreSQL method to restore SQL property modified by AddWhere and SetOrderBy.

See Also
AddWhere
SetOrderBy

10.8.3.21 TCustomDADataSet.SetOrderBy

procedure SetOrderBy(Fields: String);

Description
Use SetOrderBy to build ORDER BY clause of SELECT statement. The fields are identified by the
comma-delimited string Fields.

Note: GetOrderBy and SetOrderBy methods serve to process only quite simple queries and don't
support, for example, subqueries.

Example

Query1.SetOrderBy('DeptNo;DName');

See Also
GetOrderBy

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


63 MySQL Data Access Components

10.8.4 Events
10.8.4.1 TCustomDADataSet.AfterExecute

type
TAfterExecuteEvent = procedure (Sender: TObject; Result: Boolean) of
object;

property AfterExecute: TAfterExecuteEvent;

Description
Occurs after application executed query to database.

See Also
Execute

10.8.4.2 TCustomDADataSet.AfterUpdateExecute

type
TStatementType = (stQuery, stInsert, stUpdate, stDelete, stLock,
stRefresh);
TStatementTypes = set of TStatementType;

TUpdateExecuteEvent = procedure (Sender: TDataSet; StatementTypes:


TStatementTypes;
Params: TDAParams) of object;

property AfterUpdateExecute: TUpdateExecuteEvent;

Description
Occurs after executing insert, delete, update, lock and refresh operation. You can use
AfterUpdateExecute to read parameters of corresponding statements.

See Also
BeforeUpdateExecute

10.8.4.3 TCustomDADataSet.BeforeUpdateExecute

type
TStatementType = (stQuery,stInsert,stUpdate,stDelete,stLock,stRefresh);
TStatementTypes = set of TStatementType;

TUpdateExecuteEvent = procedure (Sender: TDataSet;


StatementTypes: TStatementTypes; Params: TDAParams) of object;

property BeforeUpdateExecute: TUpdateExecuteEvent;

Description
Occurs before executing insert, delete, update, lock and refresh operation. You can use
BeforeUpdateExecute to set parameters of corresponding statements.

See Also
AfterUpdateExecute

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 64

10.9 TCustomDASQL

10.9.1 Description

Unit
DBAccess

Description
TCustomDASQL is a base class that defines functionality for descendant classes which access
database using SQL statements. Applications never use TCustomDASQL objects directly. Instead they
use descendants of TCustomDASQL.
Use TCustomDASQL when a client application must execute SQL statement or call stored procedure
on a database server. The SQL statement should not retrieve rows from a database.

See Also
SQL demo project

10.9.2 Properties
10.9.2.1 TCustomDASQL.AutoCommit

property AutoCommit: Boolean;

Description
When True and Session.AutoCommit is True and Session.InTransaction is False, each update, insert
or delete statement is automatically committed by database server.

10.9.2.2 TCustomDASQL.Connection

property Connection: TCustomDAConnection;

Description
Use Connection to specify a connection object to use to connect to a data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its descendant class
objects.
At runtime, set Connection property to reference an instanciated TCustomDAConnection object.

10.9.2.3 TCustomDASQL.Debug

property Debug: Boolean;

Description
Set Debug to True to display statement being executed and all its parameter values. Also displays
types of parameters.

Note: To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx
under Kylix) unit.

See also:
TCustomDADataSet.Debug

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


65 MySQL Data Access Components

10.9.2.4 TCustomDASQL.FinalSQL

property FinalSQL: String;

Description
Read FinalSQL to return SQL statement with expanded macros. This is exactly the statement which
will be passed on to a database server.

10.9.2.5 TCustomDASQL.MacroCount

property MacroCount: Integer;

Description
Read MacroCount to get a number of macros associated with the Macros property.

See Also
Macros

10.9.2.6 TCustomDASQL.Macros

property Macros: TMacros;

Description
With the help of macros you can easily change SQL query text at design or run time. Marcos extend
abilities of parameters and let change conditions in WHERE clause or sort order in ORDER BY clause.
You just insert &MacroName in SQL query text and change value of macro with Macro property editor
at design time or MacroByName function at run time. At the time of opening query, macros are
replaced with their values.

See Also
TMacro
MacroByName
Params

10.9.2.7 TCustomDASQL.ParamCheck

property ParamCheck: boolean;

Description
Use ParamCheck to specify whether parameters for Params property are implicitly generated when
SQL property is changing.
Set ParamCheck to True to let TCustomDASQL automatically generate Params property for dataset
based on SQL statement.
Setting ParamCheck to False is mainly suited if the dataset component passes to a server the DDL
statements that contain, for example, declarations of stored procedures which themselves will accept
parameterized values. Default value is True.

See Also
Params

10.9.2.8 TCustomDASQL.ParamCount

property ParamCount: Integer;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 66

Description
Use ParamCount to determine how many parameters are there in Params property.

10.9.2.9 TCustomDASQL.Params

property Params: TDAParams;

Description
Contains parameters for an SQL statement.
Access Params at runtime to view and set parameter names, values, and data types dynamically (at
design time use the Parameters editor to set parameter properties). Params is a zero-based array of
parameter records. Index specifies the array element to access.
An easier way to set and retrieve parameter values when the name of each parameter is known is to
call ParamByName.

Example
Setting parameters in runtime.

procedure TForm1.Button1Click(Sender: TObject);


begin
with MySQL do
begin
SQL.Clear;
SQL.Add('INSERT INTO Temp_Table(Id, Name)');
SQL.Add('VALUES (:id, :Name)');
ParamByName('Id').AsInteger := 55;
Params[1].AsString := ' Green';
Execute;
end;
end;

See Also
TDAParam
FindParam
Macros
10.9.2.10 TCustomDASQL.ParamValues

property ParamValues[const ParamName: string]: Variant;

Description
Use ParamValues to get or set the values of individual field parameters that are identified by name.
ParamName is a string containing the names of the individual field parameters of interest. If
ParamValues is used to access more than one field parameter, the names are separated by
semicolons (;).

Setting ParamValues sets the Value property for each parameter listed in the ParamName string.
Specify the values as Variants.

Getting ParamValues retrieves a variant array of variants, each of which represents the value of one of
the named parameters.

Note Params array of parameters is generated implicitely if ParamCheck property is set to True. If
ParamName includes a name that does not match any of the field parameters in Items, an
exception is raised.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


67 MySQL Data Access Components

10.9.2.11 TCustomDASQL.Prepared

property Prepared: Boolean;

Description

Prepared property currently is not supported by MySQL and always False.

See Also
Prepare

10.9.2.12 TCustomDASQL.RowsAffected

property RowsAffected: Integer;

Description
Check RowsAffected to determine how many rows were inserted, updated or deleted during the last
query operation. If RowsAffected is -1, the query did not insert, update or delete any rows.

10.9.2.13 TCustomDASQL.SQL

property SQL: TStrings;

Description
Use SQL property to provide an SQL statement that TCustomDASQL component executes when
Execute method is called. At design time the SQL property can be edited by invoking a String List
editor in the Object Inspector.

10.9.3 Methods
10.9.3.1 TCustomDASQL.Execute

procedure Execute; overload;


procedure Execute(Iters: Integer); overload;

Description
Use Execute to execute the SQL statement on the server. If SQL statement has OUT parameters use
ParamByName method or Params property to get their values. Iters argument specifies the number of
times this statement is executed for DML array operations.

10.9.3.2 TCustomDASQL.Executing

function Executing: boolean;

Description
Check Executing to find out whether TCustomDASQL still executes SQL statement. Use Executing
method is used for nonblocking execution.
10.9.3.3 TCustomDASQL.FindMacro

function FindMacro(Name: String): TMacro;

Description
Call FindMacro to determine if a specified macro exists in a dataset. Name is the name of the macro

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 68

for which to search. If FindMacro finds a macro with a matching name, it returns the TMacro object for
the specified Name. Otherwise it returns nil.

See Also
TMacro
Macros
MacroByName

10.9.3.4 TCustomDASQL.FindParam

function FindParam(Name: String): TDAParam;

Description
Use FindParam method to find a parameter with the name passed in Name argument. If a match is
found, FindParam returns the parameter. Otherwise, it returns nil.

See Also
ParamByName

10.9.3.5 TCustomDASQL.MacroByName
Accesses macro information based on a specified macro name.

function MacroByName(Name: String): TMacro;

Description
Use MacroByName method to find a Macro with the name passed in Name argument. If a match is
found, MacroByName returns the Macro. Otherwise, an exception is raised. Use this method rather
than a direct reference to the Items property to avoid dependency on their actual ordering inside
Macros property.

To locate a parameter by name without raising an exception if the parameter is not found, use
FindMacro method.

To assign a value to the macro use TMacro.Value property.

See Also
TMacro
Macros
FindMacro

10.9.3.6 TCustomDASQL.ParamByName

function ParamByName(Name: String): TDAParam;

Description
Use ParamByName method to find a parameter with the name passed in Value.
If a match is found, ParamByName returns the parameter. Otherwise, an exception is raised.

Example

MySQL1.Execute;
Edit1.Text := MySQL1.ParamsByName('Contact').AsString;

See Also
FindParam

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


69 MySQL Data Access Components

10.9.3.7 TCustomDASQL.Prepare

procedure Prepare;

Description

Method Prepare currently is not supported by MySQL.

See Also
Prepared
UnPrepare

10.9.3.8 TCustomDASQL.UnPrepare

procedure UnPrepare;

Description
Call UnPrepare to free the resources allocated for a previously prepared query on the server and client
sides.

See Also
Prepare

10.9.3.9 TCustomDASQL.WaitExecuting

function WaitExecuting(TimeOut: integer = 0): boolean;

Description
Call WaitExecuting to wait for Timeout seconds while TCustomDASQL executes SQL statement. Use
WaitExecuting method for nonblocking execution. If TimeOut is 0 WaitExecuting waits for infinite time.

See Also
Executing

10.9.4 Events
10.9.4.1 TCustomDASQL.AfterExecute

type
TAfterExecuteEvent = procedure (Sender:TObject; Result: Boolean) of
object;

property AfterExecute: TAfterExecuteEvent;

Description
Occurs after SQL statement has been executed. Is suited for descendant components which make
use of multithreaded environment.
Result is True if SQL statement is executed successfully, False otherwise.

See Also
Execute

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 70

10.10 TCustomDASQLMonitor

10.10.1 Description

Unit
DASQLMonitor

Description
TCustomDASQLMonitor is a base class that introduces properties and methods to interactively monitor
dynamic SQL execution in database applications. TCustomDASQLMonitor provides two ways of
displaying debug information. It monitors either by dialog window or by Borland's proprietary SQL
Monitor. Furthermore to receive debug information use OnSQL event.
In applications use descendants from TCustomDASQLMonitor.

10.10.2 Properties
10.10.2.1 TCustomDASQLMonitor.Active

property Active: Boolean;

Description
Set Active property to True to activate monitoring of SQL.

See Also
OnSQL

10.10.2.2 TCustomDASQLMonitor.Options

type
TMonitorOption = (moDialog, moSQLMonitor, moDBMonitor, moCustom,
moHandled);
TMonitorOptions = set of TMonitorOption;

property Options: TMonitorOptions;

Description
Set Options to include the desired properties for TCustomDASQLMonitor. Possible values of the
Options are:

Property Meaning

moDialog Display debug information in debug window.


moSQLMonitor Display debug information in Borland SQL Monitor.
moDBMonitor Display debug information in DBMonitor.
moCustom Allow monitoring of SQL for individual components. Set Debug properties in
SQL-related components to True to let TCustomDASQLMonitor instance to
monitor their behavior. Affects when moDialog is included.
moHandled Include component hanlde into event description string.

See Also
OnSQL

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


71 MySQL Data Access Components

10.10.2.3 TCustomDASQLMonitor.TraceFlags

type
TDATraceFlag = (tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt,
tfConnect, tfTransact, tfBlob, tfService, tfMisc, tfParams);
TDATraceFlags = set of TDATraceFlag;

property TraceFlags: TDATraceFlags;

Description
Use TraceFlags to specify which database operations the monitor should track in an application at
runtime.

tfQPrepare queries preparation

tfQExecute execution of the queries

tfError errors of query execution

tfConnect establishing a connection

tfTransact processing transactions

tfMisc if this flag set then just before sending a query to the server OnSQL event is
called additionally. The difference from usual call is that the query is already
completely decoded, i.e. parameters are quoted and included into the text of
the query. If to use MySQL 4.1 protocol with preparing a value of this flag will
be ignored

tfParams representing parameter values for tfQPrepare and tfQExecute

See Also
OnSQL

10.10.3 Events
10.10.3.1 TCustomDASQLMonitor.OnSQL

type
TOnSQLEvent = procedure (Sender: TObject; Text: string; Flag:
TDATraceFlag) of object;

property OnSQL: TOnSQLEvent;

Description
Write an OnSQL event handler to let application trace SQL activity on database components. Text
parameter holds detected SQL statement. Use Flag parameter to make selective processing of SQL in
hander body.

See Also
TraceFlags

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 72

10.11 TCustomDAUpdateSQL

10.11.1 Description

Unit
DBAccess

Description
TCustomDAUpdateSQL component is the base class for components that provide DML statements for
the dataset components that return read-only result set. This component is provided for BDE
compatibility only.

See Also
UpdateObject

10.11.2 Properties
10.11.2.1 TCustomDAUpdateSQL.Dataset

property DataSet: TCustomDADataSet;

Description
DataSet property holds reference to the TCustomDADataSet object being updated. Generally it is not
used directly.
10.11.2.2 TCustomDAUpdateSQL.DeleteSQL

property DeleteSQL: TStrings;

Description
Set DeleteSQL to the SQL DELETE statement to use when applying a deletion to a record. Statements
can be parameterized queries with parameter names corresponding to dataset field names. If
parameter name is a field name prefixed with 'OLD_' then an unmodified original value for that field is
used as the parameter value.

See Also
TUpdateSQL.DeleteSQL

10.11.2.3 TCustomDAUpdateSQL.InsertSQL

property InsertSQL: TStrings;

Description
Set InsertSQL to the SQL INSERT INTO statement to use when applying an insertion to a record.
Statements can be parameterized queries with parameter names corresponding to dataset field
names. If parameter name is a field name prefixed with 'OLD_' then an unmodified original value for
that field is used as the parameter value.

See Also
TUpdateSQL.InsertSQL

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


73 MySQL Data Access Components

10.11.2.4 TCustomDAUpdateSQL.ModifySQL

property ModifySQL: TStrings;

Description
Set ModifySQL to the SQL UPDATE statement to use when applying a deletion to a record.
Statements can be parameterized queries with parameter names corresponding to dataset field
names. If parameter name is a field name prefixed with 'OLD_' then an unmodified original value for
that field is used as the parameter value.

See Also
TUpdateSQL.ModifySQL

10.11.2.5 TCustomDAUpdateSQL.RefreshSQL

property RefreshSQL: TStrings;

Description
Use SQLRefresh property to specify SQL statement that will be used for refreshing current record by
RefreshRecord procedure.
You can assign to SQLRefresh WHERE clause only. It such a case it is added to SELECT defined by
SQL property by AddWhere function.
To create SQLRefresh statement at design time, use query statements editor.

See Also
TCustomDADataSet.RefreshRecord

10.11.2.6 TCustomDAUpdateSQL.SQL

property SQL[UpdateKind: TUpdateKind]: TStrings;

Description
Returns the SQL statement for one of the ModifySQL, InsertSQL, or DeleteSQL properties, depending
on the value of the UpdateKind index.

10.11.3 Methods
10.11.3.1 TCustomDAUpdateSQL.Apply

procedure Apply(UpdateKind: TUpdateKind);

Description
Call Apply to set parameters for an SQL statement and execute it to update a record. UpdateKind
indicates which SQL statement to bind and execute, and can be one of the following values:

Value Meaning
ukDelete Bind and execute the SQL statement in the DeleteSQL property
ukInsert Bind and execute the SQL statement in the InsertSQL property
ukModify Bind and execute the SQL statement in the ModifySQL property

Apply is primarily intended for manually executing update statements from an OnUpdateRecord event
handler.

Note: If an SQL statement does not contain parameters, it is more efficient to call ExecSQL instead
of Apply.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 74

See Also
ExecSQL
10.11.3.2 TCustomDAUpdateSQL.ExecSQL

procedure ExecSQL(UpdateKind: TUpdateKind);

Description
Call ExecSQL to execute the SQL statement necessary for updating the records belonging to a read-
only result set when cached updates is enabled. UpdateKind specifies the statement to execute, and
can be one of the following values:

Value Meaning
ukDelete Execute the SQL statement in the DeleteSQL property
ukInsert Execute the SQL statement in the InsertSQL property
ukModify Execute the SQL statement in the ModifySQL property

ExecSQL is primarily intended for manually executing update statements from an OnUpdateRecord
event handler.

Note: To both bind parameters and execute a statement, call Apply.

See Also
Apply

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


75 MySQL Data Access Components

10.12 TDAParam

10.12.1 Description

Unit
DBAccess

Description
Use the properties of TDAParam to set the value of a parameter. Objects that use parameters create
TDAParam objects to represent these parameters. For example, TDAParam objects are used by
TCustomDASQL , TCustomDADataSet.

TDAParam shares many properties with TField, as both describe the value of a field in a dataset.
However, a TField object has several properties to describe the field binding, and how the field is
displayed, edited, or calculated that are not needed in a TDAParam object. Conversely, TDAParam
includes properties that indicate how the field value is passed as a parameter.

See Also
TCustomDADataSet
TCustomDASQL
TDAParams

10.12.2 Properties
10.12.2.1 TDAParam.AsBlob

property AsBlob: string;

Description
Setting AsBlob will set the DataType property to ftBlob. It is seldom necessary to read AsBlob, because
memo fields can not be used as output parameters.

10.12.2.2 TDAParam.AsBlobRef

property AsBlobRef: TBlob;

Description
Setting AsBlobRef will set the DataType property to ftBlob.

10.12.2.3 TDAParam.AsFloat

property AsFloat: Double;

Description
Set AsFloat to assign the value for a float field to the parameter. Setting AsFloat will set the DataType
property to dtFloat.
Read the AsFloat property to determine the value that was assigned to an output parameter,
represented as a Double. The value of the parameter will be converted to a Double value if possible.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 76

10.12.2.4 TDAParam.AsInteger

property AsInteger: Integer;

Description
Set AsInteger to assign the value for an integer field to the parameter. Setting AsInteger will set the
DataType property to dtInteger.
Read the AsInteger property to determine the value that was assigned to an output parameter,
represented as a 32-bit integer. The value of the parameter will be converted to a Integer value if
possible.

10.12.2.5 TDAParam.AsMemo

property AsMemo: string;

Description
Set AsMemo to assign the value for a memo field to the parameter. Setting AsMemo will set the
DataType property to ftMemo. It is seldom necessary to read AsMemo, because memo fields can not
be used as output parameters.

10.12.2.6 TDAParam.AsMemoRef

property AsMemoRef: TBlob;

Description
Setting AsMemoRef will set the DataType property to ftMemo.

10.12.2.7 TDAParam.AsString

property AsString: String;

Description
Set AsString to assign the string value to the parameter. Setting AsString will set the DataType
property to ftString.
Read the AsString property to determine the value that was assigned to an output parameter,
represented as a string. The value of the parameter will be converted to a string.

10.12.2.8 TDAParam.AsWideString

property AsWideString: String;

Description
Set AsWideString to assign the Unicode string value to the parameter. Setting AsWideString will set
the DataType property to ftWideString.
Read the AsWideString property to determine the value that was assigned to an output parameter,
represented as a Unicode string. The value of the parameter will be converted to a Unicode string.

10.12.2.9 TDAParam.DataType

property DataType: TFieldType;

Description
DataType is set automatically when a value is assigned to the parameter. Do not set DataType for
bound fields, as that may cause the assigned value to be misinterpreted.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


77 MySQL Data Access Components

Read DataType to discover the type of data that was assigned to the parameter. Each possible value
of DataType corresponds to a type of database field.

10.12.2.10 TDAParam.IsNull

property IsNull: boolean;

Description
IsNull indicates whether the value assigned to the parameter is NULL.

10.12.2.11 TDAParam.ParamType

property ParamType: TParamType;

Description
Objects that use TDAParam objects to represent field parameters set ParamType to indicate the type
of use for the parameter. ParamType must be one of the following values:

Value Description
ptUnknown Unknown or undetermined. Before executing a stored procedure, the application must
set parameters of this type to another kind.
ptInput Used to input a field value. Identifies a parameter used to pass values to a stored
procedure for processing.
ptOutput Used to output a field value. Identifies a parameter used by a stored procedure to
return values to an application.
ptInputOutput Used for both input and output.
ptResult Used as a return value. Identifies a parameter used by a stored procedure to return an
error or status value. A stored procedure can only have one parameter of type
ptResult.

10.12.2.12 TDAParam.Size

property Size: Integer;

Description
Use Size property to check actual size of String, Blob and Memo parameters.

10.12.2.13 TDAParam.Value

property Value: Variant;

Description
Value represents the value of the parameter as a Variant.
Use Value in generic code that manipulates the values of parameters without the need to know the
field type the parameter represent.

10.12.3 Methods
10.12.3.1 TDAParam.LoadFromFile

type
TBlobType = ftBlob..ftOraClob;
procedure LoadFromFile(const FileName: string; BlobType: TBlobType);

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 78

Description
Use LoadFromFile to place content of a file specified by FileName into TDAParam object. BlobType
value modifies DataType property so that this TDAParam object now holds BLOB value.

See Also
LoadFromStream

10.12.3.2 TDAParam.LoadFromStream

type
TBlobType = ftBlob..ftOraClob;
procedure LoadFromStream(Stream: TStream; BlobType: TBlobType);

Description
Use LoadFromStream to place content from a stream into TDAParam object. BlobType value modifies
DataType property so that this TDAParam object now holds BLOB value.

See Also
LoadFromFile

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


79 MySQL Data Access Components

10.13 TDAParams

10.13.1 Description

Unit
DBAccess

Description
Use TDAParams to manage a list of TDAParam objects for an object that uses field parameters. For
example, TCustomDADataSet objects and TCustomDASQL objects use TDAParams objects to create
and access their parameters.

See Also
TCustomDADataSet.Params
TCustomDASQL.Params
TDAParam

10.13.2 Properties
10.13.2.1 TDAParams.Items

property Items[Index: Integer]: TDAParam

Description
Use Items to iterate through all the field parameters. Index identifies the index in the range 0..Count -
1. Items can reference a particular parameter by its index, but the ParamByName method is preferred,
so as to avoid depending on the order of the parameters.

10.13.3 Methods
10.13.3.1 TDAParams.FindParam

function FindParam(const Value: String): TDAParam;

Description
Use FindParam method to find a parameter with the name passed in Value. If a match is found,
FindParam returns the parameter. Otherwise, it returns nil. Use this method rather than a direct
reference to the Items property to avoid depending on the order of the entries.

To locate more than one parameter at a time, by name, use the GetParamList method instead. To get
only the value of a named parameter, use the ParamValues property.

10.13.3.2 TDAParams.ParamByName

function ParamByName(const Value: String): TDAParam;

Description
Use ParamByName method to find a parameter with the name passed in Value. If a match is found,
ParamByName returns the parameter. Otherwise, an exception is raised. Use this method rather than
a direct reference to the Items property to avoid depending on the order of the entries.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 80

To locate a parameter by name without raising an exception if the parameter is not found, use the
FindParam method.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


81 MySQL Data Access Components

10.14 TMacro

10.14.1 Description

Unit
DBAccess

Description
TMacro object represents value of a macro. Macro is a variable that holds string value. You just insert
&MacroName in SQL query text and change value of macro by Macro property editor at design time or
Value property at run time. At the time of opening query macro is replaced by its value.

If by any reason it is not convenient for you to use '&' symbol as a character of macro replacement,
change the value of MacroChar variable.

See Also
TMacros

10.14.2 Properties
10.14.2.1 TMacro.Active

property Active: Boolean;

Description
When set to True the macro is expanded, otherwise macro definition is replaced by null string. You can
use Active property to modify SQL property.

The default value is True.

Example

MyQuery.SQL.Text := 'SELECT * FROM Dept WHERE DeptNo > 20 &Cond1';


MyQuery.Macros[0].Value := 'and DName is NULL';
MyQuery.Macros[0].Active:= False;

10.14.2.2 TMacro.AsDateTime

property AsDateTime: TDateTime;

Description
Use AsDataTime to set TDataTime value to macro.

10.14.2.3 TMacro.AsFloat

property AsFloat: Double;

Description
Use AsFloat to set float value to macro.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 82

10.14.2.4 TMacro.AsInteger

property AsInteger: Integer;

Description
Use AsInteger to set integer value to macro.

10.14.2.5 TMacro.AsString

property AsString: String;

Description
Set AsString to assign string value to the macro. Read the AsString property to determine the value of
macro, represented as a string.

10.14.2.6 TMacro.Name

property Name: String;

Description
Use Name to identify a particular macro.

10.14.2.7 TMacro.Value

property Value: String;

Description
Use Value to set value to macro.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


83 MySQL Data Access Components

10.15 TMacros

10.15.1 Description

Unit
DBAccess

Description
Use TMacros to manage a list of TMacro objects for TCustomDASQL or TCustomDADataSet
components

See Also
TMacro

10.15.2 Properties
10.15.2.1 TMacros.Count

property Count: Integer;

Description
Count contains the number of items in the Items array. Since Items is indexed starting with 0, the value
of Count is always one greater than the index of the last member of Items.

10.15.2.2 TMacros.Items

property Items[Index: Integer]: TMacro;

Description
Use Items to iterate through all the field parameters. Index identifies the index in the range 0..Count -
1.

10.15.3 Methods
10.15.3.1 TMacros.FindMacro

function FindMacro(Name: String): TMacro;

Description
Use FindMacro method to find a parameter with the name passed in Value. If a match is found,
FindMacro returns the parameter. Otherwise, it returns nil. Use this method rather than a direct
reference to the Items property to avoid depending on the order of the entries.

10.15.3.2 TMacros.MacroByName

function MacroByName(Name: String): TMacro;

Description
Use MacroByName method to find a Macro with the name passed in Value. If a match is found,

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 84

MacroByName returns the Macro. Otherwise, an exception is raised. Use this method rather than a
direct reference to the Items property to avoid depending on the order of the entries.

To locate a parameter by name without raising an exception if the parameter is not found, use the
FindMacro method.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


85 MySQL Data Access Components

10.16 TMemDataSet

10.16.1 Description

Unit
MemDS

Description
TMemDataSet derives from TDataSet database-engine independent set of properties, events, and
methods for working with data and introduces additional techniques to store and manipulate data in
memory.

10.16.2 Properties
10.16.2.1 TMemDataSet.CachedUpdates

property CachedUpdates: Boolean;

Description
Use CachedUpdates property to enable or disable the use of cached updates for a dataset. Setting
CachedUpdates to True enables updates to a dataset (such as posting changes, inserting new
records, or deleting records) are stored in an internal cache on the client side instead of being written
directly to the dataset's underlying database tables. When changes are complete, an application writes
all cached changes to the database in the context of a single transaction.

Cached updates are especially useful for client applications working with remote database servers.
Enabling cached updates brings up the following benefits:

• Fewer transactions and shorter transaction times.


• Minimized network traffic.

The potential drawbacks of enabling cached updates are:

• Other applications can access and change the actual data on the server while users are editing
local copies of the data, resulting in an update conflict when cached updates are applied to the
database.
• Other applications cannot access data changes made by an application until its cached updates
are applied to the database.

Default value is False.

See Also
UpdatesPending
ApplyUpdates
RestoreUpdates
CommitUpdates
CancelUpdates
UpdateStatus

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 86

10.16.2.2 TMemDataSet.IndexFieldNames

property IndexFieldNames: string;

Description
Set IndexFieldNames property to establish or change the list of fields on which the recordset is sorted.
Specify the name of each column In IndexFieldNames to use as an index for a table. Ordering of
column names is significant. Separate names with semicolon. The specified columns need not be
indexed. Set IndexFieldNames to an empty string to reset the recordset to the sort order originally used
when the recordset's data was first retrieved.

Each field may optionally be followed by the keyword ASC / DESC or CIS / CS. Use ASC, DESC
keywords to specify a sort direction for the field. If one of these keywords is not used, the default sort
direction for the field is ascending. Use CIS keyword to compare two string fields without case
sensitivity. The default value is CS - compare with case sensitivity.

Read IndexFieldNames to determine the field (or fields) on which the recordset is sorted.

Ordering is processed locally.

Note
You cannot process ordering by BLOB fields.

Example
The following procedure illustrates how to set IndexFieldNames in response to a button click:

DataSet1.IndexFieldNames := 'LastName ASC CIS; DateDue DESC';

10.16.2.3 TMemDataSet.LocalConstraints

property LocalConstraints: Boolean;

Description
Use LocalConstraints to avoid setting Required property of TField component for NOT NULL fields at
the time of opening TMemDataSet. When LocalConstrains is True TMemDataSet ignores NOT NULL
server constraints. It is useful for tables which have fields updated by triggers.

LocalConstraints is obsolete, and is only included for backward compatibility.

The default value is True.

10.16.2.4 TMemDataSet.LocalUpdate

property LocalUpdate: Boolean;

Description
Set LocalUpdate to True to prevent implicit update of rows on database server. Data changes are
cached locally in client memory.

10.16.2.5 TMemDataSet.Prepared

Determines whether or not a query is prepared for execution.

property Prepared: Boolean;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


87 MySQL Data Access Components

Description

Prepared property currently is not supported by MySQL and always False.

See Also
Prepare

10.16.2.6 TMemDataSet.UpdateRecordTypes

type
TUpdateRecordTypes = set of (rtModified, rtInserted, rtDeleted,
rtUnmodified);
property UpdateRecordTypes: TUpdateRecordTypes;

Description
Use UpdateRecordTypes property to determine the update status for the current record when cached
updates are enabled. Update status can change frequently as records are edited, inserted, or deleted.
UpdateRecordTypes offers a convenient method for applications to assess the current status before
undertaking or completing operations that depend on the update status of records.

See Also
CachedUpdates

10.16.2.7 TMemDataSet.UpdatesPending

property UpdatesPending: Boolean;

Description
Examine UpdatesPending to check the status of the cached updates buffer. If UpdatesPending is
True, then there are edited, deleted, or inserted records remaining in local cache and not yet applied to
the database. If UpdatesPending is False, there are no such records in the cache.

See Also
CachedUpdates

10.16.3 Methods
10.16.3.1 TMemDataSet.ApplyUpdates

procedure ApplyUpdates;

Description
Call ApplyUpdates to write a dataset's pending cached updates to a database. This method passes
cached data to the database for storage, but the changes are not committed to the database. An
application must explicitly call the database component's Commit method to commit the changes to the
database if the write is successful, or call the database's Rollback method to undo the changes if there
is an error.
Following a successful write to the database, and following a successful call to a connection's Commit
method, an application should call the CommitUpdates method to clear the cached update buffer.

Note
The preferred method for updating datasets is to call a database component's ApplyUpdates method
rather than to call each individual dataset's ApplyUpdates method. The database component's
ApplyUpdates method takes care of committing and rolling back transactions and clearing the cache
when the operation is successful.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 88

Example
The following procedure illustrates how to apply a dataset's cached updates to a database in response
to a button click:

procedure ApplyButtonClick(Sender: TObject);


begin
with MyQuery do
begin
Session.StartTransaction;
try
... {Modify data}

ApplyUpdates; {try to write the updates to the database}


Session.Commit; {on success, commit the changes}
except
RestoreUpdates; {restore update result for applied records}
Session.Rollback; {on failure, undo the changes}
raise; {raise the exception to prevent a call to CommitUpdates!}
end;
CommitUpdates; {on success, clear the cache}
end;
end;

See Also
CachedUpdates
CancelUpdates
CommitUpdates
UpdateStatus
10.16.3.2 TMemDataSet.CancelUpdates

procedure CancelUpdates;

Description
Clears all pending cached updates from the cache and restores the dataset in its prior state.
Calls CancelUpdates to clear all pending cached updates from the cache and restore the dataset to the
state it was in when the table was opened, cached updates were last enabled, or updates were last
successfully applied to the database.
When a dataset is closed, or the CachedUpdates property is set to False, CancelUpdates is called
automatically.

See Also
CachedUpdates
ApplyUpdates
UpdateStatus
10.16.3.3 TMemDataSet.CommitUpdates

procedure CommitUpdates;

Description
Calls CommitUpdates to clear the cached updates buffer after both a successful call to ApplyUpdates
and a database component's Commit method. Clearing the cache after applying updates ensures that
the cache is empty except for records that could not be processed and were skipped by the
OnUpdateRecord or OnUpdateError event handlers. An application can attempt to modify the records
still in the cache.
Record modifications made after a call to CommitUpdates repopulate the cached update buffer and
require a subsequent call to ApplyUpdates to move them to the database.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


89 MySQL Data Access Components

See Also
CachedUpdates
ApplyUpdates
UpdateStatus
10.16.3.4 TMemDataSet.DeferredPost

procedure DeferredPost;

Description
Call DeferredPost to make permanent changes to database server while retaining dataset in its state
whether it is dsEdit or dsInsert.
Explicit call to Cancel method after DeferredPost has been applied does not abandon modifications to
a dataset already fixed in database.

See Also
TDataSet.Post

10.16.3.5 TMemDataSet.Locate

Searches the dataset for a specified record and makes that record the current record.

function Locate(const KeyFields: string; const KeyValues: Variant;


Options: TLocateOptions): Boolean;

Description

Call Locate to search a dataset for a specific record and position the cursor on it.

KeyFields is a string containing a semicolon-delimited list of field names on which to search.

KeyValues is a variant that specifies the values to match in the key fields. If KeyFields lists a single
field, KeyValues specifies the value for that field on the desired record. To specify multiple search
values, pass a variant array as KeyValues, or construct a variant array on the fly using the VarArrayOf
routine. For example:

with CustTable do
Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P',
'408-431-1000']), [loPartialKey]);

Options is a set that optionally specifies additional search latitude when searching on string fields. If
Options contains the loCaseInsensitive setting, then Locate ignores case when matching fields. If
Options contains the loPartialKey setting, then Locate allows partial-string matching on strings in
KeyValues. If Options is an empty set, or if KeyFields does not include any string fields, Options is
ignored.

Locate returns True if it finds a matching record, and makes that record the current one. Otherwise
returns False.

10.16.3.6 TMemDataSet.LocateEx

Searches the dataset for a specified record and makes that record the current record.

type
TLocateExOption = (lxCaseInsensitive, lxPartialKey, lxNearest, lxNext,

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 90

lxUp, lxPartialCompare);
TLocateExOptions = set of TLocateExOption;

function LocateEx(const KeyFields: string; const KeyValues: Variant;


Options: TLocateExOptions): Boolean;

Description

Use LocateEx when you need some features not included to Locate method of TDataSet.

Options allows to set additional search parameters which will be using by LocateEx method.

Value Meaning

lxCaseInsensitive is the same to loCaseInsensitive. Key fields and key values are matched
without regard to case
lxPartialKey is the same to loPartialKey. Key values can include only part of the
matching key field value. For example, 'HAM' would match both 'HAMM'
and 'HAMMER.', but not 'MR HAMMER'
lxPartialCompare is similar to lxPartialKey, but as distinct from it can process value entries
in any position. For example, 'HAM' would match both 'HAMM', 'HAMMER.',
and also 'MR HAMMER'
lxNearest LocateEx moves the cursor to a specific record in a dataset or to the
first record in the dataset that is greater than the values specified in
the KeyValues parameter
lxNext LocateEx searches from the current record
lxUp LocateEx searches from the current record to first record

LocateEx returns True if it finds a matching record, and makes that record the current one. Otherwise
Locate returns False.

Note
Please add MemData unit to the "uses" list to use TLocalExOption enumeration.

See Also
Locate

10.16.3.7 TMemDataSet.Prepare

procedure Prepare;

Description

Method Prepare currently is not supported by MySQL.

See Also
Prepared
UnPrepare
10.16.3.8 TMemDataSet.RestoreUpdates

procedure RestoreUpdates;

Description
Call RestoreUpdates method to return cache of updates to its state before calling ApplyUpdates.
RestoreUpdates marks all records in cache of updates as unapplied. It is useful when ApplyUpdates
failed.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


91 MySQL Data Access Components

See Also
CachedUpdates
ApplyUpdates
CancelUpdates
UpdateStatus
10.16.3.9 TMemDataSet.RevertRecord
Restores the current record in the dataset to an unmodified state when cached updates are enabled.

procedure RevertRecord;

Description
Call RevertRecord to undo changes made to the current record when cached updates are enabled.

See Also
CachedUpdates
CancelUpdates

10.16.3.10 TMemDataSet.UnPrepare

procedure UnPrepare;

Description
Call UnPrepare to free the resources allocated for a previously prepared query on the server and client
sides.

Note
When you change the text of a query at runtime, the query is automatically closed and unprepared.

See Also
Prepare

10.16.3.11 TMemDataSet.UpdateResult

type
TUpdateAction = (uaFail, uaAbort, uaSkip, uaRetry, uaApplied);

function UpdateResult: TUpdateAction;

Description
Call UpdateResult to read the status of the latest call to ApplyUpdates method while cached updates
are enabled. UpdateResult reflects updates made on records that have been edited, inserted, or
deleted.
UpdateResult works on record by record basis and is applicable to current record only.

See Also
CachedUpdates

10.16.3.12 TMemDataSet.UpdateStatus

type
TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);

function UpdateStatus: TUpdateStatus;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 92

Description
Call UpdateStatus to determine the current update status for the dataset when cached updates are
enabled. Update status can change frequently as records are edited, inserted, or deleted.
UpdateStatus offers a convenient method for applications to assess the current status before
undertaking or completing operations that depend on the update status of the dataset.

See Also
CachedUpdates

10.16.4 Events
10.16.4.1 TMemDataSet.OnUpdateError

type
TUpdateKind = (ukModify, ukInsert, ukDelete);
TUpdateAction = (uaFail, uaAbort, uaSkip, uaRetry, uaApplied);
TUpdateErrorEvent = procedure(DataSet: TDataSet; E: EDatabaseError;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction) of object;

property OnUpdateError: TUpdateErrorEvent;

Description
Write an OnUpdateError event handler to respond to exceptions generated when cached updates are
applied to a database.

E is a pointer to a EDatabaseError object from which an application can extract an error message and
the actual cause of the error condition. An OnUpdateError handler can use this information to
determine how to respond to the error condition.
UpdateKind describes the type of update that generated the error. The following table lists the possible
values for UpdateKind and what they indicate:

Value Meaning

ukModify Editing an existing record caused an error.


ukInsert Inserting or appending a new record caused an error.
ukDelete Deleting an existing record raised an error.

UpdateAction indicates the action to take when the OnUpdateError handler exits. On entry into the
handler, UpdateAction is always set to uaFail. If OnUpdateError can handle or correct the error, set
UpdateAction to uaRetry before exiting the error handler. The following table lists the possible values
for UpdateAction and what they indicate:

Value Meaning

uaAbort Aborts the update operation without displaying an error message.


uaApplied Not used in error handling routines.
uaFail Aborts the update operation and displays an error message.
uaRetry Repeats the update operation that originally raised the error condition.
uaSkip Skips updating the record that raised the error condition, and leaves the unapplied
changes in the cache.

The error handler can use the TField.OldValue and TField.NewValue properties to evaluate error
conditions and set TField.NewValue to a new value to reapply. In this case, set UpdateAction to
uaRetry before exiting.

Note

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


93 MySQL Data Access Components

If a call to ApplyUpdates raises an exception and ApplyUpdates is not called within the context of a
try...except block, an error message is displayed. If an OnUpdateError handler cannot correct the error
condition and leaves UpdateAction set to uaFail, the error message is displayed twice. To prevent
redisplay, set UpdateAction to uaAbort in the error handler.

See Also
CachedUpdates

10.16.4.2 TMemDataSet.OnUpdateRecord

type
TUpdateKind = (ukModify, ukInsert, ukDelete);
TUpdateAction = (uaFail, uaAbort, uaSkip, uaRetry, uaApplied);
TUpdateRecordEvent = procedure(DataSet: TDataSet; UpdateKind:
TUpdateKind; var UpdateAction: TUpdateAction) of object;

property OnUpdateRecord: TUpdateRecordEvent;

Description
Write an OnUpdateRecord event handler to process updates that cannot be handled by a single
update component, such as implementation of cascading updates, insertions, or deletions. This
handler is also useful for applications that require additional control over parameter substitution in
update components.

UpdateKind describes the type of update to perform. The following table lists the possible values for
UpdateKind and what they indicate:

Value Meaning

ukModify Edit an existing record.


ukInsert Insert or append a new record.
ukDelete Delete an existing record.

UpdateAction indicates the action taken by the OnUpdateRecord handler before it exits. On entry into
the handler, UpdateAction is always set to uaFail. If OnUpdateRecord is successful, it should set
UpdateAction to uaApplied before exiting. The following table lists the possible values for UpdateAction
and what they indicate:

Value Meaning

uaAbort Abort the update operation without displaying an error message.


uaApplied Update is applied. Free update record from cache.
uaFail Aborts the update operation and displays an error message.
uaRetry Not used for record updates.
uaSkip Update is skipped. Leave update record in the cache.

See Also
CachedUpdates

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 94

10.17 TSharedObject

10.17.1 Description

Unit
MemData

Description
TSharedObject allows to simplify memory management for object referenced by several another
objects. TSharedObject holds a count of references to itself. When any object (referer object) is going
to use TSharedObject it calls TSharedObject.AddRef method. Referer object has to call
TSharedObject.Release method after using TSharedObject.

See Also
TBlob
TObjectType

10.17.2 Properties
10.17.2.1 TSharedObject.RefCount

property RefCount: Integer;

Description
Returns count of reference to TSharedObject object.

10.17.3 Methods
10.17.3.1 TSharedObject.AddRef

procedure AddRef;

Description
Increments the reference count for the number of references dependent on the TSharedObject object.

See Also
Release

10.17.3.2 TSharedObject.Release

procedure Release;

Description
Decrements the reference count. When RefCount is 1 TSharedObject is deleted from memory.

See Also
AddRef

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


95 MySQL Data Access Components

10.18 TVirtualTable

10.18.1 Description

Unit
VirtualTable

Description
TVirtualTable is inherited from TMemDataSet component. TVirtualTable stores data in memory and
does not have linked data files. To add fields to virtual table at design time use Fields Editor. Call
AddField method to add fields at run time.
Immediately after creating virtual table it will be empty. You then define new fields or load existing table
files so that virtual table object becomes initialized and ready to be opened.
When you close virtual table it will discard its record set. To keep data you entered at design time for
later use you may wish to include voStored option in Options property. At run time you will need to call
SaveToFile method explicitly to store modifications to the file that later may be retrieved back into the
virtual table by calling LoadFromFile method.

TVirtualTable supports following field types:


ftString, ftWideString, ftSmallint, ftInteger, ftAutoInc, ftWord, ftBoolean, ftLargeint, ftFloat,
ftCurrency, ftDate, ftTime, ftDateTime, ftBlob, ftMemo

10.18.2 Properties
10.18.2.1 TVirtualTable.Options

type
TVirtualTableOption = (voPersistentData, voStored);
TVirtualTableOptions = set of TVirtualTableOption;
property Options: TVirtualTableOptions;

Description
Options property specifies what actions to take on fields data at the times of opening or closing
TVirtualTable dataset.
Options may hold the following values:

Property Meaning

voPersistentData Dataset will not dispose of its data at the time of dataset closing.

voStored Dataset will keep its data set at design-time in DFM file along with other form's
stored properties.

10.18.3 Methods
10.18.3.1 TVirtualTable.AddField

procedure AddField(Name: String; FieldType: TFieldType; Size: Word);

Description
Call AddField to add new TFieldDef object with name determined by Name. FieldType can be ftString,

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 96

ftWideString, ftSmallint, ftInteger, ftAutoInc, ftWord, ftBoolean, ftLargeint, ftFloat, ftCurrency, ftDate,
ftTime, ftDateTime, ftBlob or ftMemo. When you add ftString or ftWideString field you should to specify
Size of string.

Example

VirtualTable1.AddField('CODE', ftInteger, 0);


VirtualTable1.AddField('NAME', ftString, 30);

See Also
DeleteField
DeleteFields

10.18.3.2 TVirtualTable.Assign

procedure Assign(Source: TPersistent);

Description
Use Assign to copy fields and data other TDataSet component.

Note
Unsupported field types are skipped (i.e. destination dataset will contain less fields than source one).
This may happen when Source is not a TVirtualTable component but some SQL server oriented
dataset.

Example

MyQuery1.SQL.Text := 'SELECT * FROM DEPT';


MyQuery1.Active := True;
VirtualTable1.Assign(MyQuery1);
VirtualTable1.Active := True;

See Also
TVirtualTable

10.18.3.3 TVirtualTable.Clear

procedure Clear;

Description
Use Clear to remove all records from TVirtualTable.

10.18.3.4 TVirtualTable.DeleteField

procedure DeleteField(Name: String);

Description
Use DeleteField to delete field specified by Name.

See Also
AddField
DeleteFields

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


97 MySQL Data Access Components

10.18.3.5 TVirtualTable.DeleteFields

procedure DeleteFields;

Description
Use DeleteFields to delete all fields.

See Also
DeleteField

10.18.3.6 TVirtualTable.LoadFromFile

procedure LoadFromFile(const FileName: String);

Description
Use LoadFromFile to load the data of a file into a TVirtualTable component. Specify the name of the
file to load into the field as the value of the FileName parameter.

10.18.3.7 TVirtualTable.LoadFromStream

procedure LoadFromStream(Stream: TStream);

Description
Use LoadFromStream to copy the data of a stream into the TVirtualTable component. Specify the
stream from which the field's value is copied as the value of the Stream parameter.

10.18.3.8 TVirtualTable.SaveToFile

procedure SaveToFile(const FileName: String);

Description
Use SaveToFile to save the data of the TVirtualTable component to a file. Specify the name of the file
as the value of the FileName parameter.

10.18.3.9 TVirtualTable.SaveToStream

procedure SaveToStream(Stream:TStream);

Description
Use SaveToStream to copy the data a TVirtualTable component to a stream. Specify the name of the
stream to which the field's value is saved as the value of the Stream parameter.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 98

10.19 EMyError

10.19.1 Description

Unit
MyClasses

Description
EMyError is raised when MySQL Server returns error as a result, for example, of an attempt to execute
invalid SQL statement. Use EMyError in an exception-handling block.

See Also
EDAError

10.19.2 Properties
10.19.2.1 EMyError.ErrorCode

property ErrorCode: Integer;

Description
ErrorCode contains error code returned by MySQL Server. See MySQL documentation.

See Also
EMyError

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


99 MySQL Data Access Components

10.20 MyDataAdapter

10.20.1 Description

Unit
CoreLab.MyDac.DataAdapter

Description
The MyDataAdapter class is designed for use with a TCustomMyDataSet components and use it as
data source for retrieving and saving data. MyDataAdapter provides this bridge by mapping Fill, which
changes the data in the System.Data.DataSet to match the data in the data source, and Update, which
changes the data in the data source to match the data in the System.Data.DataSet.

See Also
DADataAdapter

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 100

10.21 TCustomMyDataSet

10.21.1 Description

Unit
MyAccess

Description
TCustomMyDataSet is a base dataset component that defines functionality for classes derived from it.
Applications never use TCustomMyDataSet objects directly. Instead they use descendants of
TCustomMyDataSet, such as TMyQuery and TMyTable, which inherit its dataset-related properties and
methods.

See Also
TMyQuery
TCustomMyTable
Working with master/detail relationships

10.21.2 Properties
10.21.2.1 TCustomMyDataSet.CommandTimeout

property CommandTimeout: integer;

Description
Specifies amount of time to attempt execution of a command.
Use CommandTimeout to specify the amount of time that expires before an attempt to execute a
command is considered unsuccessful. Measured in seconds.
If a command is successfully executed prior to the expiration of the seconds specified,
CommandTimeout has no effect.

The default value is 0 (infinite).

See also:
TMyConnection.ConnectionTimeout
TMyCommand.CommandTimeout

10.21.2.2 TCustomMyDataSet.Connection

property Connection: TMyConnection;

Description
Use Connection property to specify a connection object that will be used to connect to a data store.
Set at design-time by selecting from the list of provided TCustomMyConnection objects.
At runtime, set Connection property to reference an existing TCustomMyConnection object.

See Also
TMyConnection

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


101 MySQL Data Access Components

10.21.2.3 TCustomMyDataSet.InsertId

property InsertId: Integer;

Description
Returns the ID generated for an AUTO_INCREMENT column by the previous query. Use this function
after you have performed an INSERT query into a table that contains an AUTO_INCREMENT field.

If the query does not perform an insertion into a table that contains an AUTO_INCREMENT field the
value of InsertId won't be defined.

InsertId property has sense only if SQL includes INSERT statement within itself. In case of SELECT
statements, a value of auto-increment field can be obtained from corresponding table fields.

See Also
Execute
10.21.2.4 TCustomMyDataSet.Options

type
TMyDataSetOptions = class (TDADataSetOptions)
published
property CheckRowVersion: boolean;
property EnableBoolean: boolean;
property FieldsAsString: boolean;
property FullRefresh: boolean;
property NullForZeroDate: boolean;
property QuoteNames: boolean;
property SetFieldsReadOnly: boolean;
end;

property Options: TMyDataSetOptions;

Description
Set properties of Options to specify the behaviour of TCustomMyDataSet object. The meanings of
Options' properties are:

Property Description

CheckRowVersion Determines whether the dataset checks for rows modifications made by
another user on automatic generation of SQL statement for update or delete
data. If CheckRowVersion is True and DataSet has timestamp field when the
only this field is added into WHERE clause of generated SQL statement. If
CheckRowVersion is True, but there is no timestamp field then to WHERE
clause all nonblob fields will be added. The default value is False;

EnableBoolean Specifies a method of representation of TINYINT(1) fields. If set to True these


fields will be represented as TBooleanFiled; otherwise, as TSmallintField. The
default value is True;

FieldsAsString All non-Blob fields are stored as string (native MySQL format). The default
value is False;

FullRefresh Specifies what fields to include in automatically generated SQL statement


when calling RefreshRecord method. If FullRefresh property is True, all the
fields from query are included into SQL statement to refresh single record. If
FullRefresh is False, only fields from updating table are included. The default

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 102

value is False;

NullForZeroDate For datetime fields with invalid values, for example '2002-12-32', MySQL
returns on fetch '0000-00-00' value. According to NullForZeroDate option this
value will be represented as Null or '0001-01-01' ('0100-01-01' for CLR). The
default value is True;

NumberRange Sets MaxValue and MinValue properties of TIntegerField and TFloatField to


appropriate values. The default value is False;

QuoteNames If True TCustomMyDataSet quotes all field names in autogenerated SQL


statements such as update SQL.

QueryRecCount If True TCustomDADataSet performs additional query to get records count for
this SELECT so RecordCount property reflects the actual number of records.
The default value is False;

RemoveOnRefresh When RemoveOnRefresh set to True dataset locally removes record on


refresh if it does not match filter condition (WHERE clause for refresh SQL)
anymore. The default value is True;

RequiredFields If True TCustomDADataSet sets Required property of TField objects for NOT
NULL fields. It useful when table has trigger which updates NOT NULL fields.
The default value is False;

ReturnParams Returns new value of fields to dataset after insert or update. Actual value of
field after insert or update may be different from the value stored in local
memory if the table has a trigger. When ReturnParams is True OUT
parameters of SQLInsert and SQLUpdate statements is assigned to
corresponding fields. The default value is False;

SetFieldsReadOnly Specifies whether fields not concerned to current updating table get read-only
attribute. The default value is False;

StrictUpdate TCustomDADataSet raises exception when number of the updated or deleted


records does not equal to 1. Setting this option also causes an exception if
RefreshRecord procedure returns more than one record. The exception does
not occur when you use non-SQL block. The default value is True;

TrimFixedChar Specifies whether to discard all trailing spaces in string fields of the dataset.
The default value is True.

10.21.3 Methods
10.21.3.1 TCustomMyDataSet.Lock

TLockRecordType = (lrImmediately, lrDelayed);

procedure TCustomMyDataSet.Lock(LockType: TLockRecordType);

Description
Locks current record for the current connection. Serves to prevent simultaneous editing the same
record by several users. Makes sense only for InnoDB tables and can be called only inside transaction
context.

lrImmediately checks for locking directly on calling Lock method. In this case if set

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


103 MySQL Data Access Components

Lock(lrImmediately) call to BeforeEdit event you can unable the same row in
the table to be modified by several users at the same time
lrDelayed locking is performed just at time of execution Post for this record.

If any other connection tries to modify locked record it will wait for time specified by
innodb_lock_wait_timeout server variable, by default 50 seconds.If during this time the record will not
be unlocked an exception raises.

The record is unlock on finishing transaction (Commit or Rollback).

Note:
This method is uncompatible with FetchAll property set to False.
Lock can be used only with queries returning resultset.

See Also
TCustomDAConnection.StartTransaction
TCustomDAConnection.Commit
TCustomDAConnection.Rollback
LockTable
10.21.3.2 TCustomMyDataSet.LockTable

TLockType = (ltRead, ltReadLocal, ltWrite, ltWriteLowPriority);

procedure LockTable(LockType: TLockType);

Description
Locks table for the current connection. The main purpose of this method is to speed up working with
the table.

Table can be released on:


· calling UnlockTable;
· closing connection;
· calling LockTable once more for the same connection.

If a query has several tables then a table specified in UpdatingTable is used.

ltRead all connections including current one can only read from the specified table
ltReadLocal similar to ltRead. Moreover, allows non-conflicting INSERT statements to
execute while the lock is held
ltWrite a current connection can read and write to the table. Other connections wait
for calling UnlockTable
ltWriteLowPriority you can use ltWriteLowPriority locks to allow other threads to obtain ltRead
locks while the thread is waiting for the ltWrite lock. You should only use
ltWriteLowPriority locks if you are sure that there will eventually be a time when
no threads will have a ltRead lock.

Note:
This method is uncompatible with FetchAll property set to False.

See Also
UnlockTable
Lock

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 104

10.21.3.3 TCustomMyDataSet.UnlockTable

procedure UnlockTable;

Description

Releases a table blocked by LockTable.

See Also
LockTable
Lock

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


105 MySQL Data Access Components

10.22 TCustomMyTable

10.22.1 Description

Unit
MyAccess

Description
TCustomMyTable implements functionality to access data in a table. Use TCustomMyTable properties
and methods to gain direct access to records and fields in an underlying server database without
writing SQL statements.

See Also
TMyTable
TCustomMyDataSet
TMyQuery
Working with master/detail relationships

10.22.2 Properties
10.22.2.1 TCustomMyTable.IndexDefs

property IndexDefs: TIndexDefs;

Description
Contains information about the indexes for a table.

IndexDefs is a collection of index definitions, each of which describes an available index for the table.

In contrast to BDE, can be used only for viewing list of indexes already created for the table.

As an additional request for the server is required to fill it, IndexDefs is filled onthe first call.

10.22.2.2 TCustomMyTable.Limit

property Limit: Integer;

Description
Sets number of rows retrieved from the query. If Limit is -1, all records will be obtained.

See Also
Offset
10.22.2.3 TCustomMyTable.Offset

property Offset: Integer;

Description
Allows to retrieve data from the server staring from specified row. The default value is 0.

See Also

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 106

Limit
10.22.2.4 TCustomMyTable.OrderFields

property OrderFields: String;

Description
TCustomMyTable uses OrderFields property to build ORDER BY clause of SQL statements.
Place commas to separate fields between each other in a single string.
TCustomMyTable is reopened when OrderFields property is changed.

See Also
TCustomMyTable
10.22.2.5 TCustomMyTable.TableName

property TableName: String;

Description
Use TableName to specify the name of the database table that this component encapsulates. At
design-time select a valid table name from the TableName drop-down list in the Object Inspector.

Note:
To work with temporary tables you must set FetchAll to True (for details see FetchAll description).

See Also
TCustomMyTable
TCustomDAConnection.GetTableNames

10.22.3 Methods
10.22.3.1 TCustomMyTable.EmptyTable

procedure EmptyTable;

Description
The EmptyTable method deletes all records from the database table specified by the TableName
property.

See Also
TableName

10.22.3.2 TCustomMyTable.PrepareSQL

procedure PrepareSQL;

Description
Use PrepareSQL to build query for TCustomMyTable, based on values of TableName, MasterFields,
DetailFields and OrderFields properties, and assign it to SQL property.
Note that this method does not verify any of these fields on validity of their content.

See Also
TableName
MasterFields
DetailFields
OrderFields

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


107 MySQL Data Access Components

10.23 TCustomMyStoredProc

10.23.1 Description

Unit
MyAccess

Description
TCustomMyStoredProc implements functionality to access stored procedures on a database server.
You need only to define StoredProcName property, while not bothering about writing SQL statement by
hand.
Use Execute method at runtime to generate request that instructs server to execute procedure and
return parameters in Params property.

Stored procedures are supported only for MySQL 5.0.

See also
TCustomMyDataSet
TMyStoredProc

10.23.2 Properties
10.23.2.1 TCustomMyStoredProc.StoredProcName

property StoredProcName: String;

Description
Set StoredProcName to specify the name of the stored procedure to call on the server. If
StoredProcName does not match the name of an existing stored procedure on the server, then when
the application attempts to prepare the procedure prior to execution, an exception is raised.

10.23.3 Methods
10.23.3.1 TCustomMyStoredProc.ExecProc

procedure ExecProc;

Description
Use ExecProc to execute the SQL statement on the server. If SQL statement is a query ExecProc calls
Open method.
Internally ExecProc calls inherited TCustomDADataSet.Execute method and is only included for
compatibility with BDE.

See Also
TCustomDADataSet.Execute

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 108

10.23.3.2 TCustomMyStoredProc.PrepareSQL

procedure PrepareSQL;

Description
Use PrepareSQL to build query for TCustomMyStoredProc, based on Params and StoredProcName
properties, and assign it to SQL property. Generated query is then verified to be valid and if necessary
list of parameters is modified.
PrepareSQL is called implicitly when TCustomMyStoredProc is executed.

See Also
TCustomDADataSet.Params
StoredProcName
ExecProc

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


109 MySQL Data Access Components

10.24 TMyBackup

10.24.1 Description

Unit
MyBackup

Description
Serves for backup copying specified tables on the server. Supports working in two modes defined by
Mode property - bmText and bmBinary.
A list of the tables are specified in TableNames.
Use Path property to specify path to the server.
TMyBackup works on the server side that greatly affects on performance. However, it has some
restrictions. At first, backup is performed only for the tables, database structure and user rights are not
stored. The second, files created on the server cannot be modified and deleted by MySQL tools.

Note:
When using bmBinary mode both servers must have the same format of the tables (must be the same
version). About compatibility of formats storing data please see MySQL Reference Manual.

See Also
Backup
Restore
TMyDump

10.24.2 Properties
10.24.2.1 TMyBackup.BackupPriority

type
TMyBackupPriority = (bpDefault, bpLowPriority, bpConcurrent);

property BackupPriority: TMyBackupPriority;

Description
Specifies a priority on Restore operation.
bpDefault another connections wait for finishing Restore;
bpLowPriority execution of Restore will be suspended until no other connections are reading
from the table;
bpConcurrent Restore will be executed simultaneously with queries from other connections.

Used only if Mode is bmText.

See Also
Mode
Restore

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 110

10.24.2.2 TMyBackup.Connection

property Connection: TMyConnection;

Description
Use Connection property to specify a connection object that will be used to connect to a data store.
Set at design-time by selecting from the list of provided TCustomMyConnection objects.
At run-time, set Connection property to reference an existing TCustomMyConnection object.

See Also
TMyConnection

10.24.2.3 TMyBackup.Debug

property Debug: Boolean;

Description
Set Debug property to True to display executing statement.
The default value is False.

Note:
To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx under
Kylix) unit.

See Also
TCustomDASQL.Debug
TCustomDADataSet.Debug
10.24.2.4 TMyBackup.Duplicates

type
TMyRestoreDuplicates = (bdIgnore, bdReplace, bdError);

property Duplicates: TMyRestoreDuplicates;

Description
Specifies a behaviour on detection records with repeated key fields on the execution of Restore
method.
bdIgnore ignore such records;
bdReplace replace old record with a new one;
bdError generate an error, ignore the rest part of the file.

Used only if Mode is bmText.

See Also
Mode
Restore

10.24.2.5 TMyBackup.EnclosedBy

property EnclosedBy: string;

Description
A field value can be quoted optionally by this string. By default, an empty string.

Used only if Mode is bmText.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


111 MySQL Data Access Components

See Also
Backup
Mode
EscapedBy
FieldsTerminatedBy
LinesTerminatedBy

10.24.2.6 TMyBackup.EscapedBy

property EscapedBy: string;

Description
A symbol that is a special symbol pointer. By default, '\\'.

Used only if Mode is bmText.

See Also
Backup
Mode
EnclosedBy
FieldsTerminatedBy
LinesTerminatedBy

10.24.2.7 TMyBackup.Fields

property Fields: string;

Description
A list of the fields which will be saved. If not specified, all fields will be stored.
Use this property on execution Backup for a single table (see TableNames).

Used only if Mode is bmText.

See Also
Mode
TableNames
Backup
Restore
10.24.2.8 TMyBackup.FieldsTerminatedBy

property FieldsTerminatedBy: string;

Description
A list of the fields which will be saved. If not specified, all fields will be stored.
Use this property on execution Backup for a single table (see TableNames).

Used only if Mode is bmText.

See Also
Backup
Mode
EnclosedBy
EscapedBy
LinesTerminatedBy

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 112

10.24.2.9 TMyBackup.IgnoreLines

property IgnoreLines: integer;

Description
Determines if the specified rows number at the beginning of the file will be ignored or not.
Use this property if you need:
· create non-typical formatted text file to be processed by the third-party applications
· fast load big volume data to the database generated by the third-party application.

Used only if Mode is bmText.

See Also
Mode
Restore

10.24.2.10 TMyBackup.LinesTerminatedBy

property LinesTerminatedBy: string;

Description
A string that is a row delimiter. By default, '\n'.

Used only if Mode is bmText.

See Also
Backup
Mode
EnclosedBy
EscapedBy
FieldsTerminatedBy

10.24.2.11 TMyBackup.Local

property Local: boolean;

Description
Uses on the execution of Restore method to specify that Path is a local path but not a path on the
server.

Used only if Mode is bmText.

See Also
Mode
Restore

10.24.2.12 TMyBackup.Mode

type
TMyBackupMode = (bmBinary, bmText);

property Mode: TMyBackupMode;

Description
Serves to control modes of working TMyBackup:

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


113 MySQL Data Access Components

bmBinary (by default) the fastest way of saving data. Files with the tables are copied physically to the
specified folder (Path). This mode is not supported for several table types, for
example, InnoDB.

bmText bmText - data from the tables is copied as text file. To specify its format use
EnclosedBy, EscapedBy, FieldsTerminatedBy, LinesTerminatedBy properties.
This mode can be used for all table types.

Note
By security reasons MySQL does not allow to overwrite files which already exist. Also MySQL requires
a path to the server be created beforehand.

When using bmBinary mode both servers must have the same format of the tables (must be the same
version). About compatibility of formats storing data please see MySQL Reference Manual.

See Also
Backup
Restore

10.24.2.13 TMyBackup.Path

property Path: string;

Description
A path on the server to the folder where data files will be stored. Path must exist before execution
Backup and Restore operations.

See Also
Backup
Restore
10.24.2.14 TMyBackup.TableNames

property TableNames: string;

Description
A list of the tables which will be used in the script. Table names are separated by comma or semicolon.
If an empty value, all the tables present in the database will be processed.

See Also
Backup
Restore
TCustomDAConnection.GetTableNames

10.24.3 Methods
10.24.3.1 TMyBackup.Backup

procedure Backup;

Description
Copies current tables by the specified path (see Path property).
A list of tables is specified in TableNames property. If list isn't specified all tables will be copied.
Use Mode property to specify a copy mode.

If Mode is bmBinary before backup copying of table files tables are locked on writing and Flush is
called.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 114

See Also
Mode
TableNames
Path

10.24.3.2 TMyBackup.Restore

procedure Restore;

Description
Serves to restore tables.

See Also
OnTableMsg

10.24.4 Events
10.24.4.1 TMyBackup.OnTableMsg

type
TMyTableMsgEvent = procedure (Sender: TObject; TableName: string;
MsgText: string) of object;

property OnTableMsg: TMyTableMsgEvent;

Description
This event occurs on execution Restore operation.

See Also
Restore

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


115 MySQL Data Access Components

10.25 TMyConnectDialog

10.25.1 Description

Unit
MyAccess

Description
Use TMyConnectDialog to provide dialog box for user to supply username, password and server
name. You may want to customize appearance of dialog box using this class's properties.

See Also
TCustomDAConnection.ConnectDialog

10.25.2 Properties
10.25.2.1 TMyConnectDialog.Connection

property Connection: TMyConnection;

Description
Read Connection property to find out which TMyConnection component uses TMyConnectDialog
object. This property is read-only.

See Also
TCustomDAConnection.ConnectDialog

10.25.2.2 TMyConnectDialog.DatabaseLabel

property DatabaseLabel: string;

Description
Use DatabaseLabel property to specify prompt for database edit.

See Also
TMyConnectDialog.ShowDatabase

10.25.2.3 TMyConnectDialog.PortLabel

property PortLabel: string;

Description
Use PortLabel property to specify prompt for port edit.

See Also
TMyConnectDialog.ShowPort

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 116

10.25.2.4 TMyConnectDialog.ShowDatabase

property ShowDatabase: boolean;

Description
Serves to display a field for entering database at connect dialog.
The default value is True.

See Also
TMyConnectDialog.DatabaseLabel
TMyConnectDialog.ShowPort

10.25.2.5 TMyConnectDialog.ShowPort

property ShowPort: boolean;

Description
Serves to display a field for entering port at connect dialog.
The default value is True.

See Also
TMyConnectDialog.PortLabel
TMyConnectDialog.ShowDatabase

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


117 MySQL Data Access Components

10.26 TMyCommand

10.26.1 Description

Unit
MyAccess

Description
Use TMyCommand to access database server using SQL statements.
TMyCommand object in a client application is used mainly to execute SQL statements on database
server. SQL statement should not retrieve records from a database since TMyCommand does not
provide storage for returned data.

See Also
TMyQuery

10.26.2 Properties
10.26.2.1 TMyCommand.CommandTimeout

property CommandTimeout: integer;

Description
Specifies amount of time to attempt execution of a command.
Use CommandTimeout to specify the amount of time that expires before an attempt to execute a
command is considered unsuccessful. Measured in seconds.
If a command is successfully executed prior to the expiration of the seconds specified,
CommandTimeout has no effect.

The default value is 0 (infinite).

See also:
TMyConnection.ConnectionTimeout
TCustomMyDataSet.CommandTimeout

10.26.2.2 TMyCommand.Connection

property Connection: TMyConnection;

Description
Use Connection property to specify a connection object that will be used to connect to a data store.
Set at design-time by selecting from the list of provided TMyConnection objects.
At run-time, set Connection property to reference an existing TMyConnection object.

See Also
TMyConnection
10.26.2.3 TMyCommand.InsertId

property InsertId: Integer;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 118

Description
Returns the ID generated for an AUTO_INCREMENT column by the previous query. Use this function
after you have performed an INSERT query into a table that contains an AUTO_INCREMENT field.

If the query does not perform an insertion into a table that contains an AUTO_INCREMENT field the
value of InsertId won't be defined.

See Also
Execute

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


119 MySQL Data Access Components

10.27 TMyConnection

10.27.1 Description

Unit
MyAccess

Description
TMyConnection component is used to establish connection to database server, provide customised
login support, and perform transaction control.
TMyConnection publishes connection-related properties derived from its ancestor class
TCustomDAConnection and introduces MySQL specific properties.

See Also
TCustomMyDataSet.Connection
TMyCommand.Connection
TMyScript.Connection

10.27.2 Properties
10.27.2.1 TMyConnection.Charset

property Charset: string;

Description
The current CharSet. Can be used only with Options.Direct set to False.

10.27.2.2 TMyConnection.ClientVersion

property ClientVersion: string;

Description
The version of MySQL Client library (libmysql.dll or libmysqld.dll).

See Also
Connect

10.27.2.3 TMyConnection.ConnectionTimeout

property ConnectionTimeout: Integer;

Description
Specifies amount of time to attempt a connection.
Use ConnectionTimeout property to specify the amount of time, in seconds, that can expire before an
attempt to make a connection is considered unsuccessful.

The default value is 15 seconds.

See Also

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 120

Connect
TCustomMyDataSet.CommandTimeout
TMyCommand.CommandTimeout

10.27.2.4 TMyConnection.IsolationLevel

type
TMyIsolationLevel = (ilReadCommitted, ilReadUnCommitted,
ilRepeatableRead, ilSerializable);

property IsolationLevel: TMyIsolationLevel;

Description

Use IsolationLevel property to specify extent to which all outside transactions interfere with subsequent
transactions of current connection.

Changes to IsolationLevel take effect at a time of starting new transaction or opening new connection.

IsolationLevel property accepts one of the following values:

ilReadCommitted Sets isolation level at which transaction cannot see changes made by outside
transactions until they are committed. Only dirty reads (changes made by
uncommitted transactions) are eliminated by this state of isolation level.

ilReadUnCommitted Most unrestricted level of transaction isolation. All types of data access
interferences are possible. Mainly used for browsing database and to receive
instant data with prospective changes.

ilRepeatableRead Prevents concurrent transactions from modifying data in current uncommitted


transaction. This level eliminates dirty reads as well as nonrepeatable reads
(repeatable reads of the same data in one transaction before and after outside
transactions may have started and committed).

ilSerializable Most restricted level of transaction isolation. Database server isolates data
involved in current transaction by putting additional processing on range locks.
Used to put aside all undesired effects observed in concurrent accesses to the
same set of data, but may lead to a greater latency at times of congested
database environment.

The default value is ilReadCommitted.

See Also
StartTransaction

10.27.2.5 TMyConnection.Database

property Database: String;

Description
Use Database property to specify database name that is a default source of data for SQL queries once
a connection is established.
Altering Database property makes new database name take effect immediately.

Example

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


121 MySQL Data Access Components

Setting Database='mysql' allows you to omit database specifier in SELECT statements. That is, instead
of
SELECT * FROM mysql.user;
you may just write
SELECT * FROM user

See Also
Server
Port
Username
Password
TCustomDAConnection.GetDatabaseNames

10.27.2.6 TMyConnection.Options

type
TMyConnectionOptions = class
published
property Compress: boolean;
property Direct: boolean;
property Embedded: boolean: boolean;
property KeepDesignConnected: boolean;
property NumericType: TDANumericType;
property Protocol: TMyProtocol;
end;

property Options: TMyConnectionOptions;

Description
Set properties of Options to specify the behaviour of TMyConnectionOptions object. The meanings of
Options' properties are:

Property Description

Compress Use compression on transferring data. Setting this property to True is quite
effective on transferring big volume data through slow connection. Pay
attention that each row is compressed separately. Take care on setting this
option as at some cases it might decrease fetch speed instead of increasing.
The default value is False.

Direct Work without using MySQL client library (libmysql.dll). Used only if Embedded
is disabled.

Embedded Specifies, what server will be used to connect - MySQL server or Embedded
MySQL server. You can read about features and using Embedded server at
"Using MySQL Embedded Server" article.

KeepDesignConnected Servers to open at run-time connections assigned at design-time. The default


value is True.

NumericType Specifies format of storing and representation of NUMERIC (DECIMAL) fields


for all TCustomMyDatasets, associated with the given connection. Can
possess the next values:
ntFloat The default value. Data on client side is in double
format and represent as TFloatField. Can be fast
processed but with some lost in accuracy.
ntBCD Data stores on client side as currency and represent

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 122

as TBCDField. This format allows to store data with


precision up to 0,0001.
ntFmtBCD Data on client is in TBCD format and represent as
TFmtBCDField. Allows to reflect the whole range of
possible values for MySQL MUNERIC type without
accuracy lost. Fields of this type is processed quite
slowly. This format is supported only for Delphi 6 and
higher versions.

Protocol which protocol to use when connecting to server:


mpDefault Similar to mpTCP, except that cases then you
connect to a local server and the OS supports
sockets (Unix) or named pipes (Windows), they are
used instead of TCP/IP to connect to the server.
mpTCP Use TCP/IP to connect to the server.
mpSocket Use sockets to connect to the server. Can be used
with Direct set to False and libmysql.dll 4.1.
mpPipe Use NamedPipes to connect to the server.
mpMemory To connect to the server using SharedMem. Can be
used with Direct set to False and libmysql.dll 4.1.

See Also
Server
Database
Using MySQL Embedded Server
10.27.2.7 TMyConnection.Port

property Port: integer;

Description
Use Port property to specify port number for TCP/IP connection. Note that Server property determines
the type of the connection.
The default value is 3306.

Port property can be used only if Options.Embedded set to False.

See Also
Server
Database
10.27.2.8 TMyConnection.ServerVersion

property ServerVersion: string;

Description
The version of MySQL server.

See Also
Connect

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


123 MySQL Data Access Components

10.27.3 Methods
10.27.3.1 TMyConnection.CreateDataSet

function CreateDataSet: TCustomDADataSet;

Description
CreateDataSet returns a new instance of TCustomMyDataSet class and associates it with this
connection object.

See Also
TMyConnection.CreateSQL
10.27.3.2 TMyConnection.CreateCommand

function CreateCommand: TMyCommand;

Description
CreateSQL returns a new instance of TMyCommand class and associates it with this connection
object.

See Also
TMyConnection.CreateDataSet
10.27.3.3 TMyConnection.GetExecuteInfo

procedure GetExecuteInfo(List: TStrings);

Description
Returns a result of the last query execution. Make sense for the following SQL statements:

INSERT INTO ... SELECT ...


INSERT INTO ... VALUES (...),(...),(...)...
LOAD DATA INFILE ...
ALTER TABLE
UPDATE

A description of result format you can see at MySQL Reference Manual mysql_info

Note:
If you execute a query at TCustomDADataSet.Execute with TCustomDADataSet.FetchAll set to False,
a result cannot be retrieved.

See also
TCustomDADataSet.Execute
TCustomDASQL.Execute

10.27.3.4 TMyConnection.ExecSQL

function ExecSQL(Text: string; const Params: array of Variant): Variant;

Description
Use ExecSQL method to execute any SQL statement outside of TMyQuery or TMyCommand
components. Supply Params array with values of parameters arranged in the same order as they
appear in SQL statement which itselt is passed in Text string parameter.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 124

Note: If a query doesn't have parameters (Params.Count = 0), this query will be executed faster.

10.27.3.5 TMyConnection.Ping

procedure TMyConnection.Ping;

Description
Use this method if your application has a long time intervals between accessing to the server. Ping
function allows to avoid automatic disconnection of the client by the server. You can read details at
MySQL Reference Manual (mysql_ping and wait_timeout)

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


125 MySQL Data Access Components

10.28 TMyDump

10.28.1 Description

Unit
MyDump

Description
Serves to store a database or its parts as a script and also to restore database from received script.
TMyDump by its behaviour is similar to mysqldump program.
Use Objects and TableNames properties to specify a list of objects to be stored. By default, only tables
structure and data are stored.
To generate a script call Backup or BackupQuery method. Resulted script can be viewed in SQL.
TMyDump works on client side. It causes large network loading. To backup database on server side
use TMyBackup. In difference from TMyBackup TMyDump component allows to store not only tables
but database structure including users rights.

See Also
Backup
Restore
TMyBackup

10.28.2 Properties
10.28.2.1 TMyDump.Connection

property Connection: TMyConnection;

Description
Use Connection property to specify a connection object that will be used to connect to a data store.
Set at design-time by selecting from the list of provided TCustomMyConnection objects.
At runtime, set Connection property to reference an existing TCustomMyConnection object.

See Also
TMyConnection

10.28.2.2 TMyDump.Debug

property Debug: Boolean;

Description
Set Debug property to True to display executing statement.
The default value is False.

Note: To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx
under Kylix) unit.

See Also
TCustomDASQL.Debug
TCustomDADataSet.Debug

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 126

10.28.2.3 TMyDump.Objects

type
TMyDumpObject = (doDatabase, doUsers, doTables, doData);
TMyDumpObjects = set of TMyDumpObject;

property Objects: TMyDumpObjects;

Description
Objects - enumeration of object types which will be describe on calling Backup.

doDatabase add to received script "CREATE DATABASE..." command;


doUsers store user privileges in the script;
doTables store tables structure in the script. List of the tables is specified in
TableNames. If TableNames is not set all tables are used.
doData store data from the tables. List of the tables is specified in TableNames. If
TableNames is not set all tables are used.

See Also
Backup
TableNames
10.28.2.4 TMyDump.Options

type
TMyDumpOptions = class
published
property AddDrop: boolean;
property AddLock: boolean;
property DisableKeys: boolean;
property UseExtSyntax: boolean;
property UseDelayedIns: boolean;
property GenerateHeader: boolean;
end;

property Options: TMyDumpOptions;

Description
Set properties of Options to specify the behaviour of TMyDump object. The meanings of Options'
properties are:

Property Description

AddDrop recreate objects. For example, before "CREATE TABLE" "DROP TABLEIF
EXISTS" will be added;

AddLock execute LOCK TABLE before data insertion. Used only with doData in
Objects;

DisableKeys add /*!40000 ALTER TABLE ... DISABLE KEYS */ before inserting data. Used
only with doData in Objects;

GenerateHeader add to script text comments;

UseDelayedInsert use INSERT DELAYED. Used only with doData in Objects;

UseExtSyntax use extended syntax of INSERT on data insertion. Used only with doData in
Objects.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


127 MySQL Data Access Components

See Also
Objects
Backup
TableNames
10.28.2.5 TMyDump.SQL

property SQL: TStrings;

Description
Use SQL property to store generated by Backup script. Use SQL as source on execution Restore
operation.
To separate individual commands use ';' symbols.

See Also
TMyScript.SQL
TCustomDASQL.SQL
TCustomDADataSet.SQL

10.28.2.6 TMyDump.TableNames

property TableNames: string;

Description
A list of the tables which will be used in the script. Make sense only on execution Backup and
doTables or doData set at the Objects. Table names are separated by comma or semicolon. If an
empty value, all the tables present in the database will be processed.

See Also
Backup
Objects
TCustomDAConnection.GetTableNames

10.28.3 Methods
10.28.3.1 TMyDump.Backup

procedure Backup;

Description
Generates script for further restoring with help of Restore method.
A list of the objects that will be described in the script is specified in Objects and TableNames
properties.
The received script is written to SQL.
OnBackupProgress is called for execution.

See Also
BackupQuery
Objects
TableNames
OnBackupProgress

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 128

10.28.3.2 TMyDump.BackupQuery

procedure BackupQuery(Query: string);

Description
Generates script for further restoring with help of Restore method.
A list of the objects that will be described in the script is specified in Objects and TableNames
properties.
The received script is written to SQL.
OnBackupProgress is called for execution.

BackupQuery method provides functionality like to Backup method with the following enhancement.

If set Query parameter then script with data will be generated not for all records and fields but only for
the specified in the query. For example, if for

MyDump.TableNames = 'Table1';
MyDump.Backup;

script for all data of Table1 will be generated, but for

MyDump.TableNames = 'Table1';
MyDump.BackupQuery('SELECT Field1, Field2 FROM Table1 WHERE Field1 <
10');

script will be generated to fill only Field1 and Field2, and only for the records for which Field1 < 10.

On using Query behaviour changes according to a number of tables specified in TableNames. If


names of the tables are not set (TableNames = ''), INSERT statements will be generated to the first
table from Query. For example, for

MyDump.TableNames := '';
MyDump.Backup('SELECT Field1, Field2 FROM Table1 WHERE Field1 < 10');

the following SQL statement will be generated

INSERT INTO Table1(Field1, Filed2) VALUES (...)

If the only table is assigned in TableNames then INSERT statements will insert data into this table only.
For example, for

MyDump.TableNames := 'Table2';
MyDump.Backup('SELECT Field1, Field2 FROM Table1 WHERE Field1 < 10');

the following SQL statement will be generated

INSERT INTO Table2(Field1, Filed2) VALUES (...)

If Query is set, TableNames must include not more than one name.

Note:
Query serve to process quite easy queries and on complicated statements can work incorrectly.

See Also
Backup
Objects

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


129 MySQL Data Access Components

TableNames
OnBackupProgress

10.28.3.3 TMyDump.Restore

procedure Restore;

Description
Executes script specified in SQL property.
On execution OnRestoreProgress is called.

See Also
Backup
BackupQuery
Debug

10.28.4 Events
10.28.4.1 TMyDump.OnBackupProgress

type
TMyBackupProgressEvent = procedure (Sender: TObject; TableName: string;
TableNum, TableCount, Percent: integer) of object;

property OnBackupProgress: TMyBackupProgressEvent;

Description
This event occurs on execution Backup operation.
Parameters:
· TableName - name of the table that is processed at this time;
· TableNum - number of the current table;
· TableCount - number of the tables which will be processed;
· Percent - a percent of execution current table.

See Also
Backup
TableNames
10.28.4.2 TMyDump.OnRestoreProgress

type
TMyRestoreProgressEvent = procedure (Sender: TObject; Percent: integer)
of object;

property OnRestoreProgress: TMyRestoreProgressEvent;

Description
This event occurs on execution Restore operation.

See Also
Restore

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 130

10.29 TMyQuery

10.29.1 Description

Unit
MyAccess

Description
TMyQuery is a direct descendant of TCustomMyDataSet component. It publishes most of its inherited
properties and events so that they can be manipulated at design-time.
Use TMyQuery functionality to fetch/update database tables using DML SQL statements. Set SQL,
SQLInsert, SQLDelete, SQLRefresh and SQLUpdate properties to define SQL statements for
subsequent accesses to database server. There is no restriction to their syntax, so any of SQL
statement is allowed. Usually you need to use INSERT, DELETE and UPDATE statements.
SQLInsert, SQLDelete, SQLUpdate, SQLRefresh properties support automatic binding of parameters
which have identical names to fields captions. To retrieve the value of a field as it was before operation
use the field name with 'OLD_' prefix. This is especially useful when doing field comparisons in the
WHERE clause of the statement. Use BeforeUpdateExecute event to assign value to additional
parameters and AfterUpdateExecute event to read them.
If any of SQLInsert, SQLDelete or SQLUpdate properties is undefined TMyQuery implicitly generates it
on demand before applying corresponding modification to the database. This largely depends on
UpdatingTable property.

See also
Query demo project
UpdatingTable
TCustomMyDataSet
TCustomMyTable
Working with master/detail relationships

10.29.2 Properties
10.29.2.1 TMyQuery.UpdatingTable

property UpdatingTable: String;

Description
Specifies which table in a query is assumed to be the target for subsequent data-modification queries
as a result of user incentive to insert, update or delete records.
Property UpdatingTable is used on Insert, Update, Delete or RefreshRecord (see also
Options.FullRefresh) if appropriate SQL (SQLInsert, SQLUpdate or SQLDelete) is not provided.
If UpdatingTable is not set then the first table used in query is assumed to be the target.
All fields from other than target table have their ReadOnly properties set to True (if
Options.SetFieldsReadOnly is True).

Example 1
For the query:

SELECT * FROM Dept

the only allowed value for UpdatingTable property is 'Dept'.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


131 MySQL Data Access Components

Example 2
For the query:

SELECT * FROM Dept, Emp


WHERE Dept.DeptNo = Emp.DeptNo

allowed values for UpdatingTable are 'Dept' and 'Emp'. In the first case (or by default) editable field is
ShipName, in the second – all fields from Emp.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 132

10.30 TMyLoader

10.30.1 Description

Unit
MyLoader

Description
TMyLoader serves for fast loading data to the server.
TMyLoader work is based on generation INSERT statements which insert data by several rows for one
time (see RowsPerQuery).
This class is used to simplify INSERT statements generation.

To affect on performance set MyLoader.Connection.Options.Compression property to True.

The quicker way is to generate text file on client side and load it using TMyBackup.Restore method
with Mode = bmText.

See Also
TMyBackup

10.30.2 Methods
10.30.2.1 TMyLoader.Finish

procedure Finish;

Description
Serves for forced flush data to the server. Use this method if PutColumnData is used to indicate the
end of data to be transferred.

See Also
PutColumnData

10.30.3 Properties
10.30.3.1 TMyLoader.Connection

property Connection: TMyConnection;

Description
Use Connection property to specify a connection object that will be used to connect to a data store.
Set at design-time by selecting from the list of provided TMyConnection objects.
At runtime, set Connection property to reference an existing TMyConnection object.

See Also
TMyConnection

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


133 MySQL Data Access Components

10.30.3.2 TMyLoader.Options

type
TMyLoaderOption = (loLock, loDelayed);
TMyLoaderOptions = set of TMyLoaderOption;

property Options: TMyLoaderOptions;

Description
Set properties of Options to specify the behaviour of TMyLoader object. The meanings of Options'
properties are:

Value Description

loLock lock tables while insert data;


loDelayed use INSERT DELAYED syntax.

10.30.3.3 TMyLoader.RowsPerQuery

property RowsPerQuery: integer;

Description
Gets or sets number of rows that will be send to the server for one time. The default value is 0. In this
case rows will be grouped by 16Kb (the default value of net_buffer_length).

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 134

10.31 TMyScript

10.31.1 Description

Unit
MyScript

Description
Often it is necessary to execute several SQL statements one by one. Known way is using a lot of
components such as TMyCommand. Usually it isn't a good solution. With only one TMyScript
component you can execute several SQL statements as one. To separate single statements use
semicolon (;) or slash (/). Note slash must be first character in the line.
Errors that occur while execution can be processed in OnError event handler. By default, on error
TMyScript shows exception and continues execution.

If you need to create several Stored Procedures (Functions) at the single script, use slash (\) to
separate commands for creating stored procedures.

See Also
TMyCommand

10.31.2 Properties
10.31.2.1 TMyScript.Connection

property Connection: TMyConnection;

Description
Use Connection to specify a connection object to use to connect to a data store.
Set at design-time by selecting from the list of provided TMyConnection objects.
At run-time, set Connection property to reference an existing TMyConnection object.

See Also
TMyConnection
10.31.2.2 TMyScript.DataSet

property DataSet: TCustomMyDataSet;

Description
Set DataSet property if you need to retrieve the results of SELECT statements execution inside a
script.

See Also
Execute

10.31.2.3 TMyScript.Debug

property Debug: Boolean;

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


135 MySQL Data Access Components

Description
Set Debug property to True to display executing statement and all its parameter values. Also allows to
display type of parameters.
The default value is False.

Note:
To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx under
Kylix) unit.

See Also
TCustomDASQL.Debug
TCustomDADataSet.Debug
10.31.2.4 TMyScript.Macros

property Macros: TMacros;

Description
With the help of macros you can easy change SQL statement text at design- or run-time. Macros
extend abilities of parameters and let change conditions in WHERE clause or sort order in ORDER BY
clause. You just insert &MacroName in SQL query text and change value of macro by Macro property
editor at design-time or MacroByName function at run-time. In time of opening query macro is replaced
by its value.

See Also
TMacro
MacroByName

10.31.2.5 TMyScript.SQL

property SQL: TStrings;

Description
Use SQL property to provide the sequence of SQL statements that TMyScript component executes
than Execute method is called. At design-time SQL property can be edited by the MyScript Editor.
Use ';' symbols to separate single statements.

See Also
TCustomDASQL.SQL
TCustomDADataSet.SQL

10.31.3 Methods
10.31.3.1 TMyScript.ErrorOffset

function ErrorOffset: Integer;

Description
Use ErrorOffset to get offset of error if Execute method raised an exception.

See Also
OnError

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 136

10.31.3.2 TMyScript.Execute

procedure Execute;

Description
Call Execute method to execute script. If MySQL raises an error OnError event occurs.

See Also
OnError
ErrorOffset

10.31.3.3 TMyScript.FindMacro

function FindMacro(Name: String): TMacro;

Description
Call FindMacro to determine if a specified macro exists in a dataset. Name is the name of the macro
for which to search for. If FindMacro finds a macro with a matching name, it returns the TMacro object
for the specified Name. Otherwise it returns nil.

See Also
TMacro
Macros
MacroByName

10.31.3.4 TMyScript.MacroByName

function MacroByName(Name: String): TMacro;

Description
Use MacroByName method to find a Macro with the name passed in Name. If a match is found,
MacroByName returns the Macro. Otherwise, an exception is raised. Use this method rather than a
direct reference to the Items property to avoid depending on the order of the entries.
To locate a parameter by name without raising an exception if the parameter is not found, use
FindMacro method.
To assign value of macro use TMacro.Value property.

See Also
TMacro
TCustomDADataSet.Macros
TCustomDADataSet.FindMacro

10.31.4 Events
10.31.4.1 TMyScript.BeforeExecute

type
TBeforeExecuteEvent = procedure (Sender: TObject; var SQL: String;
var Omit: Boolean) of object;

property BeforeExecute: TBeforeExecuteEvent;

Description
Write BeforeExecute event handler to take specific action before executing current SQL statement.
SQL holds text of the current SQL statement. Write SQL to change statement which will be executed.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


137 MySQL Data Access Components

Set Omit to True to skip statement execution.

See Also
Execute
10.31.4.2 TMyScript.OnError

type
TErrorAction = (eaAbort,eaFail,eaException,eaContinue);
TOnErrorEvent = procedure (Sender: TObject; E: Exception;
SQL: String; var Action: TErrorAction) of object;

property OnError: TOnErrorEvent;

Description
Occurs when MySQL raises some error.
Action indicates the action to take when OnError handler exits. On entry into the handler, Action is
always set to eaFail.

Value Meaning
eaAbort Abort the execution without displaying an error message.
eaFail Abort the execution and display an error message.
eaContinue Continue the execution.

See Also
ErrorOffset

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 138

10.32 TMyStoredProc

10.32.1 Description

Unit
MyAccess

Description
Use TMyStoredProc to access stored procedures on a database server.
You need only to define StoredProcName property, while not bothering about writing SQL statement by
hand.
Use Execute method at runtime to generate request that instructs server to execute procedure and
return parameters in Params property.

See also
TCustomMyStoredProc
TCustomMyDataSet
TMyQuery
TMyCommand

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


139 MySQL Data Access Components

10.33 TMySQLMonitor

10.33.1 Description

Unit
MyAccess

Description
Use TMySQLMonitor to monitor dynamic SQL execution in MyDAC based applications.
TMySQLMonitor provides two ways of displaying debug information: monitoring with dialog window or
by Borland's SQL Monitor. Furthermore to receive debug information use OnSQL event. Also it is
possible to use all these ways at the same time, though an application may instantiate only one
TMySQLMonitor object. If an application has none of these objects, TMySQLMonitor dialog window is
available to display debug information.

See Also
TCustomDADataSet.Debug
TCustomDASQL.Debug

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 140

10.34 TMyTable

10.34.1 Description

Unit
MyAccess

Description
Use TMyTable to access data in a table. TMyTable provides properties and methods to gain direct
access to records and fields in an underlying server database without writing SQL statements.

See also
TMyQuery
TCustomMyTable
TCustomMyDataSet
Working with master/detail relationships

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


141 MySQL Data Access Components

10.35 TMyServerControl

10.35.1 Description

Unit
MyServerControl

Description
Serves to control the server and execution of standard service tasks. List of the functions can be
divided on the following groups:
· Create and delete a database (CreateDatabase, DropDatabase);
· Flush server data (Flush);
· Manage tables (AnalyzeTable, OptimizeTable, CheckTable, RepairTable);
· Manage processes (ShowProcessList, KillProcess);
· Obtain current information about the server (ShowStatus, ShowVariables).
The last three groups show report as DataSet.

See Also
TMyQuery

10.35.2 Properties
10.35.2.1 TMyServerControl.Connection

property Connection: TMyConnection;

Description
Use Connection to specify a connection object to use to connect to a data store.
Set at design-time by selecting from the list of provided TMyConnection objects.
At run-time, set Connection property to reference an existing TMyConnection object.

See Also
TMyConnection
10.35.2.2 TMyServerControl.Debug

property Debug: Boolean;

Description
Set Debug property to True to display executing statement.
The default value is False.

Note:
To enable debug form display you should explicitly include in your project MyDacVcl (MyDacClx under
Kylix) unit.

See Also
TCustomDADataSet.Debug

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 142

10.35.2.3 TMyServerControl.TableNames

property TableNames: string;

Description
A list of the tables which will be processed by AnalyzeTable, OptimizeTable, CheckTable, RepairTable
methods.
Table names are separated by comma or semicolon. If an empty value, all tables present in the
database will be processed.

See Also
AnalyzeTable
OptimizeTable
CheckTable
RepairTable
TCustomDAConnection.GetTableNames

10.35.3 Methods
10.35.3.1 TMyServerControl.AnalyzeTable

procedure AnalyzeTable;

Description
Analyses and stores the key distribution for the table. During the analysis, the table is locked with a
read lock. This works on MyISAM and BDB tables.
This is equivalent to running myisamchk -a on the table.
If the table hasn't changed since the last AnalyzeTable command, the table will not be analysed again.
List of the tables is used from TableNames.
Refer to ANALYZE TABLE detailed description at MySQL Reference Manual.

See Also
TableNames
OptimizeTable
CheckTable
RepairTable
10.35.3.2 TMyServerControl.CheckTable

type
TMyCheckType = (ctQuick, ctFast, ctChanged, ctMedium, ctExtended);
TMyCheckTypes = set of TMyCheckType;

procedure CheckTable(CheckTypes: TMyCheckTypes = [ctMedium]);

Description
Checks MyISAM and InnoDB tables on failures.
List of the tables is used from TableNames.
Refer to CHECK TABLE detailed description at MySQL Reference Manual.

See Also
TableNames
AnalyzeTable
OptimizeTable
RepairTable

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


143 MySQL Data Access Components

10.35.3.3 TMyServerControl.CreateDatabase

procedure CreateDatabase(DatabaseName: string; IfNotExists: boolean = True;


CharsetName: string =''; CollationName: string = '');

Description
Creates a new database with the specified name.
If IfNotExists is True then a database will be created only if it doesn't exist before.
CharsetName, CollationName parameters specify language parameters of created database.

See Also
DropDatabase

10.35.3.4 TMyServerControl.DropDatabase

procedure DropDatabase(DatabaseName: string; IfExists: boolean = True);

Description
Serves to drop the specified database.
IfExists parameter is used to raise an error message if the specified database doesn't exist.

Note:
Use this function very carefully!

See Also
DropDatabase

10.35.3.5 TMyServerControl.Flush

type
TMyFlushType = (foHosts, foDesKeyFile, foLogs, foPrivileges,
foQueryCache, foTables, foStatus, foUserResources);
TMyFlushTypes = set of TMyFlushType;

procedure Flush(FlushTypes: TMyFlushTypes);

Description
Serves to flush forcedly server data from the memory to the disk. Used if backup copy is needed.
Refer to FLUSH detailed description at MySQL Reference Manual.

10.35.3.6 TMyServerControl.KillProcess

procedure KillProcess(ThreadId: integer);

Description
Use this method to break the execution of the specified process.
Refer to KILL detailed description at MySQL Reference Manual.

See Also
ShowProcessList

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 144

10.35.3.7 TMyServerControl.OptimizeTable

procedure OptimizeTable;

Description
Serves to pack tables deleting unused places from the file at the disk and defragmenting it.
It makes sense to call time from time on active working with the table especial on frequent deletion.
List of the tables is used from TableNames.
Refer to OPTIMIZE TABLE detailed description at MySQL Reference Manual.

See Also
TableNames
AnalyzeTable
CheckTable
RepairTable
10.35.3.8 TMyServerControl.RepairTable

type
TMyRepairType = (rtQuick, rtExtended, rtUseFrm);
TMyRepairTypes = set of TMyRepairType;

procedure RepairTable(RepairTypes: TMyRepairTypes = []);

Description
Repairs specified tables.
Works only with MyISAM tables.
List of the tables is used from TableNames.
Refer to REPAIR TABLE detailed description at MySQL Reference Manual.

See Also
TableNames
AnalyzeTable
OptimizeTable
CheckTable

10.35.3.9 TMyServerControl.ShowProcessList

procedure ShowProcessList(Full: boolean = False);

Description
Serves to show list of the processes. Full parameter specifies whether to show the full text of query or
only the first 100 symbols.
To disconnect use KillProcess method.

Refer to SHOW [FULL] PROCESSLIST detailed description at MySQL Reference Manual.

See Also
KillProcess
10.35.3.10 TMyServerControl.ShowVariables

procedure ShowVariables;

Description
Use this method to show the current state of the server.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


145 MySQL Data Access Components

See Also
ShowStatus
10.35.3.11 TMyServerControl.ShowStatus

procedure ShowStatus;

Description
Use this method to show the current state of the server.

See Also
ShowVariables

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 146

10.36 TMyUpdateSQL

10.36.1 Description

Unit
MyAccess

Description
Use a TMyUpdateSQL object to provide SQL statements used to update read-only datasets
represented by TMyQuery or TMyTable components when cached updates are enabled.
TMyUpdateSQL replaces behavior introduced by TUpdateSQL component and comprises functionally
equivalent properties and methods.

See Also
TUpdateSQL

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


147 MySQL Data Access Components

11 MyDAC Object and Component Listing by Unit

11.1 DALoader

11.1.1 Classes

DALoader unit implements follwing classes

TDAColumn
TDAColumns
TDALoader

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 148

11.2 DBAccess

11.2.1 Overview

Variables

ChangeCursor

ChangeCursor: boolean = True;

When set to True allows data access components to change screen cursor for execution time.

MacroChar

MacroChar: Char = '&';

Determinates what character is used for macros.

11.2.2 Classes

DBAccess unit implements follwing classes

EDAError
TCustomConnectDialog
TCustomDAConnection
TCustomDADataSet
TCustomDASQL
TCustomDAUpdateSQL
TDAParam
TDAParams
TMacro
TMacros

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


149 MySQL Data Access Components

11.3 MemData

11.3.1 Classes

MemData unit implements follwing classes

TAttribute
TBlob
TObjectType
TSharedObject

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 150

11.4 MemDS

11.4.1 Classes

MemDS unit implements follwing classes

TMemDataSet

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


151 MySQL Data Access Components

11.5 MydacVcl/MydacClx

11.5.1 Classes

MydacVcl / MydacClx unit implements follwing classes

TMyConnectDialog

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 152

11.6 MyAccess

11.6.1 Overview

Constants

MyDACVersion

Read this constant to get current version number for MyDAC. For example:

MyDACVersion = '3.00.1.3';

11.6.2 Classes

MyAccess unit implements follwing classes

TCustomMyDataSet
TMyCommand
TMyConnection
TMyQuery
TMyTable
TMyUpdateSQL

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


153 MySQL Data Access Components

11.7 MyBackup

11.7.1 Classes

MyBackup unit implements follwing classes

TMyBackup

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 154

11.8 MyLoader

11.8.1 Classes

MyLoader unit implements follwing classes

TMyLoader

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


155 MySQL Data Access Components

11.9 MyDump

11.9.1 Classes

MyDump unit implements follwing classes

TMyDump

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 156

11.10 MySqlApi

11.10.1 Overview

Variables

MySQLClientLibrary

Then set, specifies path and name of MySQL client library (libmysql.dll or libmysqld.dll for embedded
server). Not exists for .NET Framework.

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


157 MySQL Data Access Components

11.11 MyScript

11.11.1 Classes

MyScript unit implements follwing classes

TMyScript

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


MySQL Data Access Components 158

11.12 VirtualTable

11.12.1 Classes

VirtualTable unit implements follwing classes

TVirtualTable

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


159 MySQL Data Access Components

TDAParam 76

Index TMacro 82
AsWideString 33, 76
TBlob 33
TDAParam 76
-A- AutoCommit 49, 64
TCustomDADataSet 49
Active 81
TCustomDASQL 64
TCustomDASQLMonitor 70
TMacro 81
AddField 95
TVirtualTable 95
-B-
AddRef 94 Backup 113, 127
TSharedObject 94 TMyBackup 113
AddWhere 58 TMyDump 127
TCustomDADataSet 58 TMyBackup 109
AfterExecute 63, 69 BackupQuery 128
TCustomDADataSet 63 TMyDump 128
TCustomDASQL 69 BaseSQL 49
AfterUpdateExecute 63 TCustomDADataSet 49
TCustomDADataSet 63 BDE 20
AnalyzeTable 142 BeforeExecute 136
TMyServerControl 142 TMyScript 136
Apply 73 BeforeUpdateExecute 63
TCustomDAUpdateSQL 73 TCustomDADataSet 63
ApplyUpdates 87
TCustomDAConnection 42
TMemDataSet 87
-C-
AsBlob 75 CachedUpdates 85
TDAParam 75 TMemDataSet 85
AsBlobRef 75 CancelButton 37
TDAParam 75 TCustomConnectDialog 37
AsDateTime 81 CancelUpdates 88
TMacro 81 TMemDataSet 88
AsFloat 75, 81 Caption 37
TDAParam 75 TCustomConnectDialog 37
TMacro 81 Charset 119
AsInteger 76, 82 TMyConnection 119
TDAParam 76 CheckTable 142
TMacro 82 TMyServerControl 142
AsMemo 76 Clear 34, 96
TDAParam 76 TBlob 34
AsMemoRef 76 TVirtualTable 96
TDAParam 76 ClientVersion 119
Assign 34, 96 TMyConnection 119
TBlob 34 CommandTimeout 100, 117, 119
TVirtualTable 96 TCustomMyDataSet 100
AsString 33, 76, 82 TMyCommand 117
TBlob 33
MySQL Data Access Components, Copyright © 1998-2003 Core Lab
Index 160

CommandTimeout 100, 117, 119 DADataAdapter 47


TMyConnection 119 TMyScript 134
Commit 43 DataType 31, 76
TCustomDAConnection 43 TDAColumn 31
CommitUpdates 88 TDAParam 76
TMemDataSet 88 DBAccess 148
Connect 43 classes 148
TCustomDAConnection 43 overview 148
ConnectButton 37 DBMonitor 25
TCustomConnectDialog 37 DBMonitor 25
ConnectDialog 40 Debug 110, 125, 134, 141
TCustomDAConnection 40 TCustomDADataSet 49
Connection 115 TCustomDASQL 64
TCustomDADataSet 49 TMyBackup 110
TcustomDASQL 64 TMyDump 125
TCustomMyDataSet 100 TMyScript 134
TMyBackup 110 TMyServerControl 141
TMyCommand 117 DeferredPost 89
TMyConnectDialog 115 TMemDataSet 89
TMyDump 125 DeleteField 96
TMyLoader 132 TVirtualTable 96
TMyScript 134 DeleteFields 97
TMyServerControl 141 TVirtualTable 97
Count 83 DeleteSQL 72
TMacros 83 TCustomDAUpdateSQL 72
CreateCommand 123 DeleteWhere 58
TMyConnection 123 TCustomDADataSet 58
CreateDatabase 143 Detail 23
TMyServerControl 143 Master 23
CreateDataSet 43, 123 DetailFields 50
TCustomDAConnection 43 TCustomDADataSet 50
TMyConnection 123 DialogClass 37
CreateSQL 44 TCustomConnectDialog 37
TCustomDAConnection 44 Disconnect 44
TCustomDAConnection 44

-D- DropDatabase 143


TMyServerControl 143
Duplicates 110
DADataAdapter 47
TMyBackup 110
DataSet 47
Fill 47
Update 48
DALoader 147
-E-
classes 147 EDAError 30
Database 120 ErrorCode 30
TMyConnection 120 EmptyTable 106
DatabaseLabel 115 TCustomMyTable 106
TMyConnectDialog 115 EMyError 98
DataSet 47, 134 ErrorCode 98
MySQL Data Access Components, Copyright © 1998-2003 Core Lab
161 MySQL Data Access Components

EnclosedBy 110 TCustomDADataSet 59


TMyBackup 110 TCustomDASQL 67
ErrorCode 30, 98 TMacros 83
EDAError 30 TMyScript 136
EMyError 98 FindParam 79
ErrorOffset 135 TCustomDADataSet 59
TMyScript 135 TCustomDASQL 68
EscapedBy 111 TDAParams 79
TMyBackup 111 Finish 132
ExecProc 107 TMyLoader 132
TCustomMyStoredProc 107 Flush 143
ExecSQL 123 TMyServerControl 143
TCustomDAConnection 44
TCustomDAUpdateSQL 74
TMyConnection 123 -G-
Execute 136
GetBlob 60
TCustomConnectDialog 39
TCustomDADataSet 60
TCustomDADataSet 58
GetDatabaseNames 44
TCustomDASQL 67
TCustomDAConnection 44
TMyScript 136
GetDataType 60
Executing 58, 67
TCustomDADataSet 60
TCustomDADataSet 58
GetExecuteInfo 123
TCustomDASQL 67
TMyConnection 123
GetFieldObject 60
-F- TCustomDADataSet 60
GetFieldPrecision 60
FetchAll 50 TCustomDADataSet 60
TCustomDADataSet 50 GetFieldScale 60
Fetched 58 TCustomDADataSet 60
TCustomDADataSet 58 GetOrderBy 61
Fetching 59 TCustomDADataSet 61
TCustomDADataSet 59 GetServerList 39
FetchingAll 59 TCustomConnectDialog 39
TCustomDADataSet 59 GetStoredProcNames 45
FetchRows 51 TCustomDAConnection 45
TCustomDADataSet 51 GetTableNames 45
Fields 111 TCustomDAConnection 45
TMyBackup 111
FieldsTerminatedBy 111
TMyBackup 111 -I-
Fill 47
IgnoreLines 112
DADataAdapter 47
TMyBackup 112
FilterSQL 51
IndexDefs 105
TCustomDADataSet 51
TCustomMyTable 105
FinalSQL 51, 65
IndexFieldNames 86
TCustomDADataSet 51
TMemDataSet 86
TCustomDASQL 65
InsertId 101, 117
FindMacro 83, 136
MySQL Data Access Components, Copyright © 1998-2003 Core Lab
Index 162

InsertId 101, 117 Locate 89


TCustomMyDataSet 101 TMemDataSet 89
TMyCommand 117 LocateEx 89
InsertSQL 72 TMemDataSet 89
TCustomDAUpdateSQL 72 Lock 102
InTransaction 40 TCustomMyDataSet 102
TCustomDAConnection 40 LockTable 103
IsNull 77 TCustomMyDataSet 103
TDAParam 77
IsolationLevel 120
TMyConnection 120 -M-
IsQuery 51
MacroByName 83, 136
TCustomDADataSet 51
TCustomDADataSet 61
IsUnicode 33
TCustomDASQL 68
TBlob 33
TMacros 83
Items 32, 79, 83
TMyScript 136
TDAColumns 32
MacroCount 51, 65
TDAParams 79
TCustomDADataSet 51
TMacros 83
TCustomDASQL 65
Macros 135
-K- TCustomDADataSet 52
TCustomDASQL 65
KillProcess 143 TMyScript 135
TMyServerControl 143 Master 23
Detail 23

-L- MasterFields 52
TCustomDADataSet 52
MasterSource 52
LabelSet 38
TCustomDADataSet 52
TCustomConnectDialog 38
MemData 149
Limit 105
classes 149
TCustomMyTable 105
MemDS 150
LinesTerminatedBy 112
classes 150
TMyBackup 112
Mode 112
LoadFromFile 34, 77, 97
TMyBackup 112
TBlob 34
ModifySQL 73
TDAParam 77
TCustomDAUpdateSQL 73
TVirtualTable 97
MyAccess 152
LoadFromStream 34, 78, 97
classes 152
TBlob 34
overview 152
TDAParam 78
MyBackup 153
TVirtualTable 97
classes 153
Local 112
MyDataAdapter 99
TMyBackup 112
MyDump 155
LocalConstraints 86
classes 155
TMemDataSet 86
MyLoader 154
LocalUpdate 86
classes 154
TMemDataSet 86

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


163 MySQL Data Access Components

MyScript 157
classes 157
MySqlApi 156 -P-
overview 156
ParamByName 79
TCustomDADataSet 61
-N- TCustomDASQL 68
TDAParams 79
Name 31, 82 ParamCheck 54, 65
TDAColumn 31 TCustomDADataSet 54
TMacro 82 TCustomDASQL 65
ParamCount 54, 65

-O- TCustomDADataSet 54
TCustomDASQL 65
Params 54, 66
Objects 126
TCustomDADataSet 54
TMyDump 126
TCustomDASQL 66
Offset 105
ParamType 77
TCustomMyTable 105
TDAParam 77
OnBackupProgress 129
ParamValues 66
TMyDump 129
TCustomDASQL 66
OnError 137
Password 40
TCustomDAConnection 46
TCustomDAConnection 40
TMyScript 137
PasswordLabel 38
OnRestoreProgress 129
TCustomConnectDialog 38
TMyDump 129
Path 113
OnSQL 71
TMyBackup 113
TCustomDASQLMonitor 71
Ping 124
OnTableMsg 114
TMyConnection 124
TMyBackup 114
Pooling 41
OnUpdateError 92
TCustomDAConnection 41
TMemDataSet 92
TCustomDAConnection 41
OnUpdateRecord 93
Port 122
TMemDataSet 93
TMyConnection 122
OptimizeTable 144
PortLabel 115
TMyServerControl 144
TMyConnectDialog 115
Options 95, 133
Prepare 90
TCustomDADataSet 53
TCustomDADataSet 62
TCustomDASQLMonitor 70
TCustomDASQL 69
TCustomMyDataSet 101
TMemDataSet 90
TMyConnection 121
Prepared 86
TMyDump 126
TCustomDASQL 67
TMyLoader 133
TMemDataSet 86
TVirtualTable 95
PrepareSQL 106, 108
OrderFields 106
TCustomMyStoredProc 108
TCustomMyTable 106
TCustomMyTable 106

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Index 164

Server 42

-R- TCustomDAConnection 42
ServerLabel 38
TCustomConnectDialog 38
Read 35
ServerVersion 122
TBlob 35
TMyConnection 122
TCustomDADataSet 55
SetOrderBy 62
RefCount 94
TCustomDADataSet 62
TSharedObject 94
ShowDatabase 116
RefreshOptions 55
TMyConnectDialog 116
TCustomDADataSet 55
ShowPort 116
RefreshRecord 62
TMyConnectDialog 116
TCustomDADataSet 62
ShowProcessList 144
RefreshSQL 73
TMyServerControl 144
TCustomDAUpdateSQL 73
ShowStatus 145
Release 94
TMyServerControl 145
TSharedObject 94
ShowVariables 144
RepairTable 144
TMyServerControl 144
TMyServerControl 144
Size 33, 77
Restore 114, 129
TBlob 33
TMyBackup 114
TDAParam 77
TMyDump 129
SQL 127, 135
RestoreSQL 62
TCustomDADataSet 55
TCustomDADataSet 62
TCustomDASQL 67
RestoreUpdates 90
TCustomDAUpdateSQL 73
TMemDataSet 90
TMyDump 127
Retries 38
TMyScript 135
TCustomConnectDialog 38
TCustomDADataSet 56
RevertRecord 91
SQLInsert 56
TMemDataSet 91
TCustomDADataSet 56
Rollback 45
SQLRefresh 56
TCustomDAConnection 45
TCustomDADataSet 56
RowsAffected 55, 67
SQLUpdate 57
TCustomDADataSet 55
TCustomDADataSet 57
TCustomDASQL 67
StartTransaction 46
RowsPerQuery 133
TCustomDAConnection 46
TMyLoader 133
StoredProcName 107
TCustomMyStoredProc 107
-S- StoreLogInfo 38
TCustomConnectDialog 38
SavePassword 38
TCustomConnectDialog 38
SaveToFile 35, 97 -T-
TBlob 35
TableName 106
TVirtualTable 97
TCustomMyTable 106
SaveToStream 35, 97
TMyBackup 113
TBlob 35
TMyDump 127
TVirtualTable 97
TMyServerControl 142
MySQL Data Access Components, Copyright © 1998-2003 Core Lab
165 MySQL Data Access Components

TBDEDataSet 20 StartTransaction 46
TBlob 33 Username 42
Assign 34 TCustomDADataSet 49
AsString 33 AddWhere 58
AsWideString 33 AfterExecute 63
Clear 34 AfterUpdateExecute 63
IsUnicode 33 AutoCommit 49
LoadFromFile 34 BaseSQL 49
LoadFromStream 34 BeforeUpdateExecute 63
Read 35 Connection 49
SaveToFile 35 Debug 49
SaveToStream 35 DeleteWhere 58
Size 33 DetailFields 50
Truncate 35 Execute 58
Write 35 Executing 58
TCustomConnectDialog 37 FetchAll 50
CancelButton 37 Fetched 58
Caption 37 Fetching 59
ConnectButton 37 FetchingAll 59
DialogClass 37 FetchRows 51
Execute 39 FilterSQL 51
GetServerList 39 FinalSQL 51
LabelSet 38 FindMacro 59
PasswordLabel 38 FindParam 59
Retries 38 GetBlob 60
SavePassword 38 GetDataType 60
ServerLabel 38 GetFieldObject 60
StoreLogInfo 38 GetFieldPrecision 60
UsernameLabel 39 GetFieldScale 60
TCustomDAConnection 40 GetOrderBy 61
ApplyUpdates 42 IsQuery 51
Commit 43 MacroByName 61
Connect 43 MacroCount 51
ConnectDialog 40 Macros 52
CreateDataSet 43 MasterFields 52
CreateSQL 44 MasterSource 52
Disconnect 44 Options 53
ExecSQL 44 ParamByName 61
GetDatabaseNames 44 ParamCheck 54
GetStoredProcNames 45 ParamCount 54
GetTableNames 45 Params 54
InTransaction 40 Prepare 62
OnError 46 ReadOnly 55
Password 40 RefreshOptions 55
Pooling 41 RefreshRecord 62
PoolingOptions 41 RestoreSQL 62
Rollback 45 RowsAffected 55
Server 42 SetOrderBy 62

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Index 166

TCustomDADataSet 49 InsertId 101


SQL 55 Lock 102
SQLDelete 56 LockTable 103
SQLInsert 56 Options 101
SQLRefresh 56 UnlockTable 104
SQLUpdate 57 TCustomMyStoredProc 107
UniDirectional 57 ExecProc 107
UpdateObject 57 PrepareSQL 108
TCustomDASQL 64 StoredProcName 107
AfterExecute 69 TCustomMyTable 105
AutoCommit 64 EmptyTable 106
Connection 64 IndexDefs 105
Debug 64 Limit 105
Execute 67 Offset 105
Executing 67 OrderFields 106
FinalSQL 65 PrepareSQL 106
FindMacro 67 TableName 106
FindParam 68 TDAColumn 31
MacroByName 68 DataType 31
MacroCount 65 Name 31
Macros 65 TDAColumns 32
ParamByName 68 Items 32
ParamCheck 65 TDAParam 75
ParamCount 65 AsBlob 75
Params 66 AsBlobRef 75
ParamValues 66 AsFloat 75
Prepare 69 AsInteger 76
Prepared 67 AsMemo 76
RowsAffected 67 AsMemoRef 76
SQL 67 AsString 76
UnPrepare 69 AsWideString 76
WaitExecuting 69 DataType 76
TCustomDASQLMonitor 70 IsNull 77
Active 70 LoadFromFile 77
OnSQL 71 LoadFromStream 78
Options 70 ParamType 77
TraceFlags 71 Size 77
TCustomDAUpdateSQL 72 Value 77
Apply 73 TDAParams 79
DeleteSQL 72 FindParam 79
ExecSQL 74 Items 79
InsertSQL 72 ParamByName 79
ModifySQL 73 TDatabase 20
RefreshSQL 73 TDBDataSet 20
SQL 73 TMacro 81
TCustomMyDataSet 100 Active 81
CommandTimeout 100 AsDateTime 81
Connection 100 AsFloat 81

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


167 MySQL Data Access Components

TMacro 81 TableNames 113


AsInteger 82 TMyCommand 117
AsString 82 CommandTimeout 117
Name 82 Connection 117
Value 82 InsertId 117
Count 83 TMyConnectDialog 115
FindMacro 83 Connection 115
Items 83 DatabaseLabel 115
MacroByName 83 PortLabel 115
TMemDataSet 85 ShowDatabase 116
ApplyUpdates 87 ShowPort 116
CachedUpdates 85 TMyConnection 119
CancelUpdates 88 Charset 119
CommitUpdates 88 ClientVersion 119
DeferredPost 89 CommandTimeout 119
IndexFieldNames 86 CreateCommand 123
LocalConstraints 86 CreateDataSet 123
LocalUpdate 86 Database 120
Locate 89 ExecSQL 123
LocateEx 89 GetExecuteInfo 123
OnUpdateError 92 IsolationLevel 120
OnUpdateRecord 93 Options 121
Prepare 90 Ping 124
Prepared 86 Port 122
RestoreUpdates 90 ServerVersion 122
RevertRecord 91 TMyDump 125
UnPrepare 91 Backup 127
UpdateRecordTypes 87 BackupQuery 128
UpdateResult 91 Connection 125
UpdatesPending 87 Debug 125
UpdateStatus 91 Objects 126
TMyBackup 109 OnBackupProgress 129
Backup 113 OnRestoreProgress 129
BackupPriority 109 Options 126
Connection 110 Restore 129
Debug 110 SQL 127
Duplicates 110 TableNames 127
EnclosedBy 110 TMyLoader 132
EscapedBy 111 Connection 132
Fields 111 Finish 132
FieldsTerminatedBy 111 Options 133
IgnoreLines 112 RowsPerQuery 133
LinesTerminatedBy 112 TMyQuery 23, 130
Local 112 UpdatingTable 130
Mode 112 TMyScript 134
OnTableMsg 114 BeforeExecute 136
Path 113 Connection 134
Restore 114 DataSet 134

MySQL Data Access Components, Copyright © 1998-2003 Core Lab


Index 168

TMyScript 134 LoadFromFile 97


Debug 134 LoadFromStream 97
ErrorOffset 135 Options 95
Execute 136 SaveToFile 97
FindMacro 136 SaveToStream 97
MacroByName 136
Macros 135
OnError 137 -U-
SQL 135
UniDirectional 57
TMyServerControl 141
TCustomDADataSet 57
AnalyzeTable 142
UnlockTable 104
CheckTable 142
TCustomMyDataSet 104
Connection 141
UnPrepare 91
CreateDatabase 143
TCustomDASQL 69
Debug 141
TMemDataSet 91
DropDatabase 143
Update 48
Flush 143
DADataAdapter 48
KillProcess 143
TCustomDADataSet 57
OptimizeTable 144
UpdateRecordTypes 87
RepairTable 144
TMemDataSet 87
ShowProcessList 144
UpdateResult 91
ShowStatus 145
TMemDataSet 91
ShowVariables 144
UpdatesPending 87
TableNames 142
TMemDataSet 87
TMySQLMonitor 139
UpdateStatus 91
TMyStoredProc 138
TMemDataSet 91
TMyTable 23, 140
UpdatingTable 130
TMyUpdateSQL 146
TMyQuery 130
TQuery 20
Username 42
Trace 25
TCustomDAConnection 42
TraceFlags 71
TCustomConnectDialog 39
TCustomDASQLMonitor 71
Truncate 35
TBlob 35
TSession 20
-V-
TSharedObject 94 Value 77, 82
AddRef 94 TDAParam 77
RefCount 94 TMacro 82
Release 94 VirtualTable 158
TStoredProc 20 classes 158
TTable 20
TUpdateSQL 20
TVirtualTable 95
-W-
AddField 95 WaitExecuting 69
Assign 96 TCustomDASQL 69
Clear 96 Write 35
DeleteField 96 TBlob 35
DeleteFields 97

MySQL Data Access Components, Copyright © 1998-2003 Core Lab