home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1996 August
/
VPR9608A.BIN
/
del20try
/
install
/
data.z
/
DB.INT
< prev
next >
Wrap
Text File
|
1996-05-08
|
31KB
|
839 lines
{*******************************************************}
{ }
{ Delphi Visual Component Library }
{ }
{ Copyright (c) 1995,96 Borland International }
{ }
{*******************************************************}
unit DB;
{$N+,P+,S-,R-}
interface
uses SysUtils, Windows, Bde, Classes;
const
{ TDataSet maximum number of record buffers }
dsMaxBufferCount = 1024;
{ Maximum string field size }
dsMaxStringSize = 8192;
{ SQL Trace buffer size }
smTraceBufSize = 8192 + SizeOf(TraceDesc);
{ TDBDataSet flags }
dbfOpened = 0;
dbfPrepared = 1;
dbfExecSQL = 2;
dbfTable = 3;
dbfFieldList = 4;
dbfIndexList = 5;
dbfStoredProc = 6;
dbfExecProc = 7;
type
{ Forward declarations }
TDBError = class;
TSession = class;
TDatabase = class;
TFieldDefs = class;
TDataSet = class;
TDBDataSet = class;
TField = class;
TDataSource = class;
TDataLink = class;
{ Generic types }
PFieldDescList = ^TFieldDescList;
TFieldDescList = array[0..1023] of FLDDesc;
PIndexDescList = ^TIndexDescList;
TIndexDescList = array[0..63] of IDXDesc;
{ Exception classes }
EDatabaseError = class(Exception);
EDBEngineError = class(EDatabaseError)
public
constructor Create(ErrorCode: DBIResult);
destructor Destroy; override;
property ErrorCount: Integer;
property Errors[Index: Integer]: TDBError;
end;
{ BDE error information type }
TDBError = class
public
constructor Create(Owner: EDBEngineError; ErrorCode: DBIResult;
NativeError: Longint; Message: PChar);
property Category: Byte;
property ErrorCode: DBIResult;
property SubCode: Byte;
property Message: string;
property NativeError: Longint;
end;
{ TLocale }
TLocale = Pointer;
{ TBDECallback }
TBDECallbackEvent = function(CBInfo: Pointer): CBRType of Object;
TBDECallback = class
protected
function Invoke(CallType: CBType; CBInfo: Pointer): CBRType;
public
constructor Create(AOwner: TObject; Handle: hDBICur; CBType: CBType;
CBBuf: Pointer; CBBufSize: Integer; CallbackEvent: TBDECallbackEvent;
Chain: Boolean);
destructor Destroy; override;
end;
{ TSessionList }
TSessionList = class(TObject)
public
constructor Create;
destructor Destroy; override;
property CurrentSession: TSession;
function FindSession(const SessionName: string): TSession;
procedure GetSessionNames(List: TStrings);
function OpenSession(const SessionName: string): TSession;
property Count: Integer;
property Sessions[Index: Integer]: TSession; default;
property List[const SessionName: string]: TSession;
end;
{ TSession }
TConfigMode = (cmPersistent, cmSession, cmAll);
TPasswordEvent = procedure(Sender: TObject; var Continue: Boolean) of Object;
TDatabaseEvent = (dbOpen, dbClose, dbAdd, dbRemove, dbAddAlias, dbDeleteAlias);
TDatabaseNotifyEvent = procedure(DBEvent: TDatabaseEvent; const Param) of object;
TBDEInitProc = procedure(Session: TSession);
TTraceFlag = (tfQPrepare, tfQExecute, tfError, tfStmt, tfConnect,
tfTransact, tfBlob, tfMisc, tfVendor);
TTraceFlags = set of TTraceFlag;
TWriteProc = function (Client: TObject; Data: PChar; Len: Integer): LongBool; StdCall;
TSMRegProc = function (Handle: Integer; ClientName: PChar;
var WriteProc: TWriteProc; Instance: TObject;
const SignalProc: Pointer): TObject; StdCall;
TSession = class(TComponent)
protected
procedure Loaded; override;
property OnDBNotify: TDatabaseNotifyEvent;
property BDEOwnsLoginCbDb: Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AddAlias(const Name, Driver: string; List: TStrings);
procedure AddStandardAlias(const Name, Path, DefaultDriver: string);
property ConfigMode: TConfigMode;
procedure AddPassword(const Password: string);
procedure Close;
procedure CloseDatabase(Database: TDatabase);
procedure DeleteAlias(const Name: string);
procedure DropConnections;
function FindDatabase(const DatabaseName: string): TDatabase;
procedure GetAliasNames(List: TStrings);
procedure GetAliasParams(const AliasName: string; List: TStrings);
function GetAliasDriverName(const AliasName: string): string;
procedure GetConfigParams(const Path, Section: string; List: TStrings);
procedure GetDatabaseNames(List: TStrings);
procedure GetDriverNames(List: TStrings);
procedure GetDriverParams(const DriverName: string; List: TStrings);
function GetPassword: Boolean;
procedure GetTableNames(const DatabaseName, Pattern: string;
Extensions, SystemTables: Boolean; List: TStrings);
procedure GetStoredProcNames(const DatabaseName: string; List: TStrings);
function IsAlias(const Name: string): Boolean;
procedure ModifyAlias(Name: string; List: TStrings);
procedure Open;
function OpenDatabase(const DatabaseName: string): TDatabase;
procedure RemoveAllPasswords;
procedure RemovePassword(const Password: string);
procedure SaveConfigFile;
property DatabaseCount: Integer;
property Databases[Index: Integer]: TDatabase;
property Handle: HDBISES;
property Locale: TLocale;
property TraceFlags: TTraceFlags;
published
property Active: Boolean default False;
property KeepConnections: Boolean default True;
property NetFileDir: string;
property PrivateDir: string;
property SessionName: string;
property OnPassword: TPasswordEvent;
property OnStartup: TNotifyEvent;
end;
{ TParamList }
TParamList = class(TObject)
public
constructor Create(Params: TStrings);
destructor Destroy; override;
property Buffer: PChar;
property FieldCount: Integer;
property FieldDescs: PFieldDescList;
end;
{ TDatabase }
TTransIsolation = (tiDirtyRead, tiReadCommitted, tiRepeatableRead);
TLoginEvent = procedure(Database: TDatabase;
LoginParams: TStrings) of object;
TDatabase = class(TComponent)
protected
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure ApplyUpdates(const DataSets: array of TDBDataSet);
procedure Close;
procedure CloseDataSets;
procedure Commit;
procedure FlushSchemaCache(const TableName: string);
procedure Open;
procedure Rollback;
procedure StartTransaction;
procedure ValidateName(const Name: string);
property DataSetCount: Integer;
property DataSets[Index: Integer]: TDBDataSet;
property Directory: string;
property Handle: HDBIDB;
property IsSQLBased: Boolean;
property InTransaction: Boolean;
property Locale: TLocale;
property Session: TSession;
property Temporary: Boolean;
property SessionAlias: Boolean;
property TraceFlags: TTraceFlags;
published
property AliasName: string;
property Connected: Boolean default False;
property DatabaseName: string;
property DriverName: string;
property KeepConnection: Boolean default True;
property LoginPrompt: Boolean default True;
property Params: TStrings;
property SessionName: string;
property TransIsolation: TTransIsolation default tiReadCommitted;
property OnLogin: TLoginEvent;
end;
{ TDataSetDesigner }
TDataEvent = (deFieldChange, deRecordChange, deDataSetChange,
deDataSetScroll, deLayoutChange, deUpdateRecord, deUpdateState,
deCheckBrowseMode, dePropertyChange, deFieldListChange,
deFocusControl);
TDataSetDesigner = class(TObject)
public
constructor Create(DataSet: TDataSet);
destructor Destroy; override;
procedure BeginDesign;
procedure DataEvent(Event: TDataEvent; Info: Longint); virtual;
procedure EndDesign;
property DataSet: TDataSet;
end;
{ TFieldDef }
TFieldClass = class of TField;
TFieldType = (ftUnknown, ftString, ftSmallint, ftInteger, ftWord,
ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,
ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic,
ftFmtMemo, ftParadoxOle, ftDBaseOle, ftTypedBinary);
TFieldDef = class
public
constructor Create(Owner: TFieldDefs; const Name: string;
DataType: TFieldType; Size: Word; Required: Boolean; FieldNo: Integer);
destructor Destroy; override;
function CreateField(Owner: TComponent): TField;
property BDECalcField: Boolean;
property DataType: TFieldType;
property FieldClass: TFieldClass;
property FieldNo: Integer;
property Name: string;
property Required: Boolean;
property Size: Word;
end;
{ TFieldDefs }
TFieldDefs = class
public
constructor Create(DataSet: TDataSet);
destructor Destroy; override;
procedure Add(const Name: string; DataType: TFieldType; Size: Word;
Required: Boolean);
procedure AddFieldDesc(FieldDesc: FLDDesc; Required: Boolean;
FieldNo: Word);
procedure Assign(FieldDefs: TFieldDefs);
procedure Clear;
function Find(const Name: string): TFieldDef;
function IndexOf(const Name: string): Integer;
procedure Update;
property Count: Integer;
property Items[Index: Integer]: TFieldDef; default;
end;
{ TDataSet }
TBookmark = Pointer;
TBookmarkStr = String;
PBufferList = ^TBufferList;
TBufferList = array[0..dsMaxBufferCount - 1] of PChar;
TDataSetState = (dsInactive, dsBrowse, dsEdit, dsInsert,
dsSetKey, dsCalcFields, dsUpdateNew, dsUpdateOld, dsFilter);
TGetMode = (gmCurrent, gmNext, gmPrior);
TFilterOption = (foCaseInsensitive, foNoPartialCompare);
TFilterOptions = set of TFilterOption;
TLocateOption = (loCaseInsensitive, loPartialKey);
TLocateOptions = set of TLocateOption;
TResyncMode = set of (rmExact, rmCenter);
TKeyIndex = (kiLookup, kiRangeStart, kiRangeEnd, kiCurRangeStart,
kiCurRangeEnd, kiSave);
PKeyBuffer = ^TKeyBuffer;
TKeyBuffer = record
Modified: Boolean;
Exclusive: Boolean;
FieldCount: Integer;
Data: record end;
end;
TDataAction = (daFail, daAbort, daRetry);
TDataSetNotifyEvent = procedure(DataSet: TDataSet) of object;
TDataSetErrorEvent = procedure(DataSet: TDataSet; E: EDatabaseError;
var Action: TDataAction) of object;
TUpdateStatus = (usUnmodified, usModified, usInserted, usDeleted);
TUpdateKind = (ukModify, ukInsert, ukDelete);
TUpdateAction = (uaFail, uaAbort, uaSkip, uaRetry, uaApplied);
TUpdateRecordTypes = set of (rtModified, rtInserted, rtDeleted, rtUnmodified);
TUpdateErrorEvent = procedure(DataSet: TDataSet; E: EDatabaseError;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction) of object;
TUpdateRecordEvent = procedure(DataSet: TDataSet; UpdateKind: TUpdateKind;
var UpdateAction: TUpdateAction) of object;
TOnServerYieldEvent = procedure(DataSet: TDataSet; var AbortQuery: Boolean) of object;
TDataSetUpdateObject = class(TComponent)
protected
function GetDataSet: TDataSet; virtual; abstract;
procedure SetDataSet(ADataSet: TDataSet); virtual; abstract;
procedure Apply(UpdateKind: TUpdateKind); virtual; abstract;
property DataSet: TDataSet;
end;
TFilterRecordEvent = procedure(DataSet: TDataSet;
var Accept: Boolean) of object;
TRecNoStatus = (rnDbase, rnParadox, rnNotSupported);
PRecInfo = ^TRecInfo;
TRecInfo = record
UpdateStatus: TUpdateStatus;
RecordNumber: Longint;
end;
TDataOperation = function: DBIResult of object;
TDataSet = class(TComponent)
procedure BeginInsertAppend;
procedure BindFields(Binding: Boolean);
function CachedUpdateCallBack(CBInfo: Pointer): CBRType;
procedure CalculateBDEFields;
procedure CalculateFields;
procedure CheckCanModify;
procedure CheckCachedUpdateMode;
procedure CheckFieldName(const FieldName: string);
procedure CheckFieldNames(const FieldNames: string);
procedure CheckOperation(Operation: TDataOperation;
ErrorEvent: TDataSetErrorEvent);
procedure CheckRequiredFields;
procedure CheckSetKeyMode;
procedure CopyBuffer(SourceIndex, DestIndex: Integer);
function CreateExprFilter(const Expr: string;
Options: TFilterOptions; Priority: Integer): HDBIFilter;
procedure CreateFields;
function CreateFuncFilter(FilterFunc: Pointer;
Priority: Integer): HDBIFilter;
function CreateLookupFilter(Fields: TList; const Values: Variant;
Options: TLocateOptions; Priority: Integer): HDBIFilter;
procedure DeactivateFilters;
function DeleteRecord: DBIResult;
procedure DestroyFields;
function EditRecord: DBIResult;
procedure EndInsertAppend;
function FieldByNumber(FieldNo: Integer): TField;
function FindRecord(Restart, GoForward: Boolean): Boolean;
procedure FreeFieldBuffers;
procedure FreeKeyBuffers;
function GetActive: Boolean;
function GetBookmarkStr: TBookmarkStr;
procedure GetCalcFields(Index: Integer);
function GetField(Index: Integer): TField;
function GetFieldCount: Integer;
function GetFieldValue(const FieldName: string): Variant;
procedure GetIndexInfo;
function GetNextRecord: Boolean;
function GetNextRecords: Integer;
function GetPriorRecord: Boolean;
function GetPriorRecords: Integer;
function GetRecord(Index: Integer; GetMode: TGetMode): DBIResult;
function GetRecordCount: Longint;
function GetUpdatesPending: Boolean;
function InitKeyBuffer(Buffer: PKeyBuffer): PKeyBuffer;
procedure InitRecord(Buffer: PChar);
procedure InternalClose;
procedure InternalOpen;
function LocateRecord(const KeyFields: string; const KeyValues: Variant;
Options: TLocateOptions; SyncCursor: Boolean): Boolean;
function MapsToIndex(Fields: TList; CaseInsensitive: Boolean): Boolean;
procedure MoveBuffer(CurIndex, NewIndex: Integer);
procedure PostKeyBuffer(Commit: Boolean);
function PostRecord: DBIResult;
function RecordFilter(RecBuf: Pointer; RecNo: Integer): Smallint; stdcall;
procedure RemoveDataSource(DataSource: TDataSource);
procedure RemoveField(Field: TField);
procedure SetActive(Value: Boolean);
procedure SetBookmarkStr(const Value: TBookmarkStr);
procedure SetBufferCount(Value: Integer);
procedure SetBufListSize(Value: Integer);
procedure SetCurrentRecord(Index: Integer);
procedure SetField(Index: Integer; Value: TField);
procedure SetFieldDefs(Value: TFieldDefs);
procedure SetFieldValue(const FieldName: string; const Value: Variant);
procedure SetFilterData(const Text: string; Options: TFilterOptions);
procedure SetFiltered(Value: Boolean);
procedure SetFilterHandle(var Filter: HDBIFilter; Value: HDBIFilter);
procedure SetFilterOptions(Value: TFilterOptions);
procedure SetFilterText(const Value: string);
procedure SetOnFilterRecord(const Value: TFilterRecordEvent);
procedure SetOnUpdateError(UpdateEvent: TUpdateErrorEvent);
procedure SetState(Value: TDataSetState);
procedure UpdateBufferCount;
function UpdateCallbackRequired: Boolean;
procedure UpdateFieldDefs;
function YieldCallBack(CBInfo: Pointer): CBRType;
protected
procedure CheckInactive;
procedure ClearBuffers;
procedure CloseCursor; virtual;
function CreateHandle: HDBICur; virtual;
procedure DataEvent(Event: TDataEvent; Info: Longint); virtual;
procedure DestroyHandle; virtual;
procedure DestroyLookupCursor; virtual;
procedure DoAfterCancel; virtual;
procedure DoAfterClose; virtual;
procedure DoAfterDelete; virtual;
procedure DoAfterEdit; virtual;
procedure DoAfterInsert; virtual;
procedure DoAfterOpen; virtual;
procedure DoAfterPost; virtual;
procedure DoBeforeCancel; virtual;
procedure DoBeforeClose; virtual;
procedure DoBeforeDelete; virtual;
procedure DoBeforeEdit; virtual;
procedure DoBeforeInsert; virtual;
procedure DoBeforeOpen; virtual;
procedure DoBeforePost; virtual;
procedure DoOnCalcFields; virtual;
procedure DoOnNewRecord; virtual;
function GetCanModify: Boolean; virtual;
function GetDataSource: TDataSource; virtual;
function GetIndexField(Index: Integer): TField;
function GetIndexFieldCount: Integer;
function GetKeyBuffer(KeyIndex: TKeyIndex): PKeyBuffer;
function GetKeyExclusive: Boolean;
function GetKeyFieldCount: Integer;
function GetLookupCursor(const KeyFields: string;
CaseInsensitive: Boolean): HDBICur; virtual;
function GetRecordNumber: Longint; virtual;
procedure InitFieldDefs; virtual;
procedure Loaded; override;
procedure OpenCursor; virtual;
procedure PrepareCursor; virtual;
function ResetCursorRange: Boolean;
function SetCursorRange: Boolean;
procedure SetIndexField(Index: Integer; Value: TField);
procedure SetKeyBuffer(KeyIndex: TKeyIndex; Clear: Boolean);
procedure SetKeyExclusive(Value: Boolean);
procedure SetKeyFieldCount(Value: Integer);
procedure SetKeyFields(KeyIndex: TKeyIndex; const Values: array of const);
procedure SetLinkRanges(MasterFields: TList);
procedure SetLocale(Value: TLocale);
procedure SetName(const Value: TComponentName); override;
procedure SwitchToIndex(const IndexName, TagName: string);
procedure GetChildren(Proc: TGetChildProc); override;
procedure SetChildOrder(Component: TComponent; Order: Integer); override;
property InfoQueryMode: Boolean;
procedure SetCachedUpdates(Value: Boolean);
procedure SetupCallBack(Value: Boolean);
function ProcessUpdates(UpdCmd: DBIDelayedUpdCmd): DBIResult;
function GetUpdateRecordSet: TUpdateRecordTypes;
procedure SetUpdateRecordSet(RecordTypes: TUpdateRecordTypes);
procedure SetUpdateObject(Value: TDataSetUpdateObject);
function ForceUpdateCallback: Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function ActiveBuffer: PChar;
procedure Append;
procedure AppendRecord(const Values: array of const);
procedure Cancel;
procedure CheckBrowseMode;
procedure ClearFields;
procedure Close;
function ControlsDisabled: Boolean;
procedure CursorPosChanged;
procedure Delete;
procedure DisableControls;
procedure Edit;
procedure EnableControls;
procedure FetchAll;
function FieldByName(const FieldName: string): TField;
function FindField(const FieldName: string): TField;
function FindFirst: Boolean;
function FindLast: Boolean;
function FindNext: Boolean;
function FindPrior: Boolean;
procedure First;
procedure FreeBookmark(Bookmark: TBookmark);
function GetBookmark: TBookmark;
function GetCurrentRecord(Buffer: PChar): Boolean;
procedure GetFieldList(List: TList; const FieldNames: string);
procedure GetFieldNames(List: TStrings);
procedure GotoBookmark(Bookmark: TBookmark);
procedure Insert;
procedure InsertRecord(const Values: array of const);
function IsLinkedTo(DataSource: TDataSource): Boolean;
procedure Last;
function Locate(const KeyFields: string; const KeyValues: Variant;
Options: TLocateOptions): Boolean;
function Lookup(const KeyFields: string; const KeyValues: Variant;
const ResultFields: string): Variant;
function MoveBy(Distance: Integer): Integer;
procedure Next;
procedure Open;
procedure Post;
procedure Prior;
procedure Refresh;
procedure Resync(Mode: TResyncMode);
procedure SetFields(const Values: array of const);
procedure SetDetailFields(MasterFields: TList);
procedure UpdateCursorPos;
procedure UpdateRecord;
procedure ApplyUpdates;
procedure CommitUpdates;
procedure CancelUpdates;
procedure RevertRecord;
function UpdateStatus: TUpdateStatus;
property BOF: Boolean;
property Bookmark: TBookmarkStr;
property CanModify: Boolean;
property DataSource: TDataSource;
property DefaultFields: Boolean;
property Designer: TDataSetDesigner;
property EOF: Boolean;
property ExpIndex: Boolean;
property FieldCount: Integer;
property FieldDefs: TFieldDefs;
property Fields[Index: Integer]: TField;
property FieldValues[const FieldName: string]: Variant; default;
property Found: Boolean;
property Handle: HDBICur;
property KeySize: Word;
property Locale: TLocale;
property Modified: Boolean;
property RecordCount: Longint;
property RecNo: Longint;
property RecordSize: Word;
property State: TDataSetState;
property UpdateObject: TDataSetUpdateObject;
property UpdateRecordTypes: TUpdateRecordTypes;
property UpdatesPending: Boolean;
published
property Active: Boolean default False;
property AutoCalcFields: Boolean default True;
property CachedUpdates: Boolean default False;
property Filter: string;
property Filtered: Boolean default False;
property FilterOptions: TFilterOptions default [];
property BeforeOpen: TDataSetNotifyEvent;
property AfterOpen: TDataSetNotifyEvent;
property BeforeClose: TDataSetNotifyEvent;
property AfterClose: TDataSetNotifyEvent;
property BeforeInsert: TDataSetNotifyEvent;
property AfterInsert: TDataSetNotifyEvent;
property BeforeEdit: TDataSetNotifyEvent;
property AfterEdit: TDataSetNotifyEvent;
property BeforePost: TDataSetNotifyEvent;
property AfterPost: TDataSetNotifyEvent;
property BeforeCancel: TDataSetNotifyEvent;
property AfterCancel: TDataSetNotifyEvent;
property BeforeDelete: TDataSetNotifyEvent;
property AfterDelete: TDataSetNotifyEvent;
property OnNewRecord: TDataSetNotifyEvent;
property OnCalcFields: TDataSetNotifyEvent;
property OnFilterRecord: TFilterRecordEvent;
property OnServerYield: TOnServerYieldEvent;
property OnUpdateError: TUpdateErrorEvent;
property OnUpdateRecord: TUpdateRecordEvent;
property OnEditError: TDataSetErrorEvent;
property OnPostError: TDataSetErrorEvent;
property OnDeleteError: TDataSetErrorEvent;
end;
{ TDBDataSet }
TUpdateMode = (upWhereAll, upWhereChanged, upWhereKeyOnly);
TDBFlags = set of 0..15;
TDBDataSet = class(TDataSet)
protected
procedure CloseCursor; override;
procedure Disconnect; virtual;
procedure OpenCursor; override;
procedure SetDBFlag(Flag: Integer; Value: Boolean); virtual;
property DBFlags: TDBFlags;
property UpdateMode: TUpdateMode default upWhereAll;
public
function CheckOpen(Status: DBIResult): Boolean;
property Database: TDatabase;
property DBHandle: HDBIDB;
property DBLocale: TLocale;
property DBSession: TSession;
published
property DatabaseName: string;
property SessionName: string;
end;
{ TDataSource }
TDataChangeEvent = procedure(Sender: TObject; Field: TField) of object;
TDataSource = class(TComponent)
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Edit;
function IsLinkedTo(DataSet: TDataSet): Boolean;
property State: TDataSetState;
published
property AutoEdit: Boolean default True;
property DataSet: TDataSet;
property Enabled: Boolean default True;
property OnStateChange: TNotifyEvent;
property OnDataChange: TDataChangeEvent;
property OnUpdateData: TNotifyEvent;
end;
{ TField }
TFieldKind = (fkData, fkCalculated, fkLookup);
TFieldNotifyEvent = procedure(Sender: TField) of object;
TFieldGetTextEvent = procedure(Sender: TField; var Text: string;
DisplayText: Boolean) of object;
TFieldSetTextEvent = procedure(Sender: TField; const Text: string) of object;
TFieldRef = ^TField;
TField = class(TComponent)
protected
procedure AccessError(const TypeName: string);
procedure CheckInactive;
procedure Change; virtual;
procedure DataChanged;
procedure DefineProperties(Filer: TFiler); override;
procedure FreeBuffers; virtual;
function GetAsBoolean: Boolean; virtual;
function GetAsCurrency: Currency; virtual;
function GetAsDateTime: TDateTime; virtual;
function GetAsFloat: Double; virtual;
function GetAsInteger: Longint; virtual;
function GetAsString: string; virtual;
function GetAsVariant: Variant; virtual;
function GetCanModify: Boolean;
function GetDefaultWidth: Integer; virtual;
function GetParentComponent: TComponent; override;
procedure GetText(var Text: string; DisplayText: Boolean); virtual;
function HasParent: Boolean; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure PropertyChanged(LayoutAffected: Boolean);
procedure ReadState(Reader: TReader); override;
procedure SetAsBoolean(Value: Boolean); virtual;
procedure SetAsCurrency(Value: Currency); virtual;
procedure SetAsDateTime(Value: TDateTime); virtual;
procedure SetAsFloat(Value: Double); virtual;
procedure SetAsInteger(Value: Longint); virtual;
procedure SetAsString(const Value: string); virtual;
procedure SetAsVariant(const Value: Variant); virtual;
procedure SetDataType(Value: TFieldType);
procedure SetSize(Value: Word);
procedure SetParentComponent(AParent: TComponent); override;
procedure SetText(const Value: string); virtual;
procedure SetVarValue(const Value: Variant); virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
procedure AssignValue(const Value: TVarRec);
procedure Clear; virtual;
procedure FocusControl;
function GetData(Buffer: Pointer): Boolean;
function IsValidChar(InputChar: Char): Boolean; virtual;
procedure SetData(Buffer: Pointer);
procedure SetFieldType(Value: TFieldType); virtual;
property AsBoolean: Boolean;
property AsCurrency: Currency;
property AsDateTime: TDateTime;
property AsFloat: Double;
property AsInteger: Longint;
property AsString: string;
property AsVariant: Variant;
property AttributeSet: string;
property BDECalcField: Boolean;
property CanModify: Boolean;
property DataSet: TDataSet;
property DataSize: Word;
property DataType: TFieldType;
property DisplayName: string;
property DisplayText: string;
property EditMask: string;
property EditMaskPtr: string;
property FieldKind: TFieldKind;
property FieldNo: Integer;
property IsIndexField: Boolean;
property IsNull: Boolean;
property Size: Word;
property Text: string;
property Value: Variant;
property NewValue: Variant;
property OldValue: Variant;
published
property Alignment: TAlignment default taLeftJustify;
property Calculated: Boolean default False;
property DisplayLabel: string;
property DisplayWidth: Integer;
property FieldName: string;
property Index: Integer;
property Lookup: Boolean default False;
property LookupDataSet: TDataSet;
property LookupKeyFields: string;
property LookupResultField: string;
property KeyFields: string;
property ReadOnly: Boolean default False;
property Required: Boolean default False;
property Visible: Boolean default True;
property OnChange: TFieldNotifyEvent;
property OnGetText: TFieldGetTextEvent;
property OnSetText: TFieldSetTextEvent;
property OnValidate: TFieldNotifyEvent;
end;
{ TDataLink }
TDataLink = class(TPersistent)
protected
procedure ActiveChanged; virtual;
procedure CheckBrowseMode; virtual;
procedure DataSetChanged; virtual;
procedure DataSetScrolled(Distance: Integer); virtual;
procedure FocusControl(Field: TFieldRef); virtual;
procedure EditingChanged; virtual;
procedure LayoutChanged; virtual;
procedure RecordChanged(Field: TField); virtual;
procedure UpdateData; virtual;
public
constructor Create;
destructor Destroy; override;
function Edit: Boolean;
procedure UpdateRecord;
property Active: Boolean;
property ActiveRecord: Integer;
property BufferCount: Integer;
property DataSet: TDataSet;
property DataSource: TDataSource;
property DataSourceFixed: Boolean;
property Editing: Boolean;
property ReadOnly: Boolean;
property RecordCount: Integer;
end;
const
dsEditModes = [dsEdit, dsInsert, dsSetKey];
function AnsiToNative(Locale: TLocale; const AnsiStr: string;
NativeStr: PChar; MaxLen: Integer): PChar;
procedure NativeToAnsi(Locale: TLocale; NativeStr: PChar;
var AnsiStr: string);
procedure AnsiToNativeBuf(Locale: TLocale; Source, Dest: PChar; Len: Integer);
procedure NativeToAnsiBuf(Locale: TLocale; Source, Dest: PChar; Len: Integer);
function NativeCompareStr(Locale: TLocale; const S1, S2: string; Len: Integer): Integer;
function NativeCompareStrBuf(Locale: TLocale; const S1, S2: PChar; Len: Integer): Integer;
function NativeCompareText(Locale: TLocale; const S1, S2: string; Len: Integer): Integer;
function NativeCompareTextBuf(Locale: TLocale; const S1, S2: PChar; Len: Integer): Integer;
function ExtractFieldName(const Fields: string; var Pos: Integer): string;
procedure RegisterFields(const FieldClasses: array of TFieldClass);
procedure DatabaseError(const Message: string);
procedure DBError(Ident: Word);
procedure DBErrorFmt(Ident: Word; const Args: array of const);
procedure DbiError(ErrorCode: DBIResult);
procedure Check(Status: DBIResult);
procedure RegisterBDEInitProc(const InitProc: TBDEInitProc);
var
Session: TSession;
Sessions: TSessionList;
const
RegisterFieldsProc: procedure(const FieldClassess: array of TFieldClass) = nil;
implementation