📄 ezaccess2000.pas
字号:
'This column is the identifier for the entities';
// Specify whether this column allows NULLs. The Nullable property
// = Access's Required property but the specification is inverted:
//
// If Nullable = false then Required = true
Properties['Nullable'].Value := false;
end;
Table.Columns.Append(Column1, Unassigned, Unassigned);
Column2 := CoColumn.Create;
with Column1 do
begin
ParentCatalog := Catalog;
Name := 'DELETED';
Type_ := adBoolean;
// A bug in ADO 2.5 means that the Default property value will not be
// accepted and no error will be given. This bug is not in 2.1 or 2.6.
Properties['Default'].Value := False;
// Specify a human-readable string description of the column.
//
// Note that you must use the expanded syntax in order to write to
// the Properties collection. If you try to use an abbreviated syntax
// based on the Properties collection default (Value), such as:
//
// Properties['x'] := false
//
// you will get a compiler error about trying to write to a read-only
// property.
Properties['Description'].Value :=
'This column indicates if the entity is considered deleted';
// Specify whether this column allows NULLs. The Nullable property
// = Access's Required property but the specification is inverted:
//
// If Nullable = false then Required = true
Properties['Nullable'].Value := false;
end;
Table.Columns.Append(Column2, Unassigned, Unassigned);
For I := 0 To AFieldList.count - 1 Do
Begin
s:= AFieldList[I];
LoadField;
If Not v Then
EzGisError( SErrWrongField );
Column:= CoColumn.Create;
Case ft[1] Of
'C':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
// The adVarWchar and adWchar types produce Unicode (WideString) strings
// in Access 2000. If you are creating an Access 97 database you will
// get adVarChar and adChar (ANSI) strings instead.
Type_ := adVarChar;
// DefinedSize only has meaning for strings (but not memos).
DefinedSize := fl; // characters
// Specify a human-readable string description of the column.
//
// Note that you must use the expanded syntax in order to write to
// the Properties collection. If you try to use an abbreviated syntax
// based on the Properties collection default (Value), such as:
//
// Properties['x'] := false
//
// you will get a compiler error about trying to write to a read-only
// property.
//Properties['Description'].Value :=
// 'This column is part 1 of a multi-column primary key';
// Specify whether this column allows NULLs. The Nullable property
// = Access's Required property but the specification is inverted:
//
// If Nullable = false then Required = true
Properties['Nullable'].Value := false;
// Determines whether zero-length strings can be inserted into this
// column. Ignored for data types that are not strings. This is similar
// to the Nullable property but distinct. Zero-length strings are not
// NULLs in Jet.
Properties['Jet OLEDB:Allow Zero Length'].Value := false;
// Determines whether Jet should compress UNICODE strings on the disk.
// This applies only to the version 4.0 .mdb file format and is ignored
// when running against all other storage formats. The default is true.
//Properties['Jet OLEDB:Compressed UNICODE Strings'].Value := true;
end;
end;
'F', 'N':
If fd = 0 Then
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adInteger;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end Else
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adDouble;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'M':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adLongVarChar;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'G', 'B':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adVarBinary;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'L':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adBoolean;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'D':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adDBDate;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'T':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adDBTime;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
'I':
begin
with Column do
begin
ParentCatalog := Catalog;
Name := fs;
Type_ := adInteger;
//Properties['Default'].Value := 0;
//Properties['Jet OLEDB:Column Validation Text'].Value :=
// 'Please enter a number greater than or equal to 1'; adBoolean
//Properties['Description'].Value :=
// 'This column is the identifier for the entities';
//Properties['Nullable'].Value := false;
end;
end;
End;
Table.Columns.Append(Column, Unassigned, Unassigned);
End;
{ append table to catalog }
Catalog.Tables.Append( Table );
// Refresh the database schema
Catalog.Tables.Refresh;
{ create indexes }
Index1 := CoIndex.Create;
with Index1 do
begin
Name := Column1.Name;
Columns.Append(Column1.Name, Column1.Type_, Column1.DefinedSize);
PrimaryKey := false;
Unique := true;
end;
{ create primary key }
Index2 := CoIndex.Create;
with Index2 do
begin
Name := 'PrimaryKey';
Columns.Append(Column1.Name, Column1.Type_, Column1.DefinedSize);
// The SortOrder property only has meaning for index columns.
// adSortAscending is the default.
Columns[Column1.Name].SortOrder := adSortAscending;
PrimaryKey := True;
// The Unique property here seems to be ignored when the PrimaryKey
// property is true, hence the use of the MIndex1 & MIndex2 objects
// above.
Unique := True;
// Columns which are null will not have an index entry.
// adIndexNullsDisallow is the default.
IndexNulls := adIndexNullsDisallow;
// Specify whether the index is clustered. The default is false.
// Access does not support clustering, but SQL Server does.
Clustered := false;
end;
{ append indexes to tables }
Table.Indexes.Append(Index1, EmptyParam);
{ append primary keys to tables }
Table.Indexes.Append(Index2, EmptyParam);
Catalog.Set_ActiveConnection(Unassigned);
Catalog := nil;
End;
Constructor TEzADOXTable.Create( Gis: TEzBaseGis; Const FName: String;
ReadWrite, Shared: boolean );
var
AccessMdb: string;
Begin
inherited Create( Gis, FName, ReadWrite, Shared );
if Length(FName) > 0 then
begin
AccessMdb:= ChangeFileExt( Gis.FileName, '.mdb' );
If not ADOConnection.Connected then
begin
{ the connection string must be already defined in main unit }
ADOConnection.Connected:= true;
end;
FADOTable:= TADOTable.Create( Nil );
With FADOTable Do
Begin
Connection := ADOConnection;
TableName:= ChangeFileExt( ExtractFileName( FName ), '' );
ReadOnly:= Not ReadWrite;
//Exclusive:= Not Shared;
Open;
End;
end;
End;
Destructor TEzADOXTable.Destroy;
Begin
If FADOTable <> Nil then
FADOTable.Free;
Inherited Destroy;
End;
Function TEzADOXTable.GetActive: boolean;
Begin
result := FADOTable.Active;
End;
Procedure TEzADOXTable.SetActive( Value: boolean );
Begin
FADOTable.Active := value;
End;
Function TEzADOXTable.GetRecNo: Integer;
Begin
result := FADOTable.FieldByName( 'UID' ).AsInteger;
End;
Procedure TEzADOXTable.SetRecNo( Value: Integer );
Begin
if FADOTable.IndexName <> '' then
begin
FADOTable.IndexName := ''; // primary index
If Not FADOTable.Locate( 'UID',Value, [] ) Then
EzGisError( 'Record not found !' );
end else
begin
if FADOTable.FieldByName( 'UID' ).AsInteger <> Value then
begin
If Not FADOTable.Locate( 'UID',Value, [] ) Then
EzGisError( 'Record not found !' );
end;
end;
End;
Procedure TEzADOXTable.Append( NewRecno: Integer );
Begin
FADOTable.Insert;
FADOTable.FieldByName( 'UID' ).AsInteger := NewRecno;
FADOTable.Post;
End;
Function TEzADOXTable.BOF: Boolean;
Begin
result := FADOTable.BOF;
End;
Function TEzADOXTable.EOF: Boolean;
Begin
result := FADOTable.EOF;
End;
Function TEzADOXTable.DateGet( Const FieldName: String ): TDateTime;
Begin
result := FADOTable.FieldByName( FieldName ).AsDateTime;
End;
Function TEzADOXTable.DateGetN( FieldNo: integer ): TDateTime;
Begin
result := FADOTable.Fields[FieldNo - 1].AsdateTime;
End;
Function TEzADOXTable.Deleted: Boolean;
Begin
result := FADOTable.FieldByName( 'DELETED' ).AsBoolean;
End;
Function TEzADOXTable.Field( FieldNo: integer ): String;
Begin
result := FADOTable.Fields[FieldNo - 1].FieldName;
End;
Function TEzADOXTable.FieldCount: integer;
Begin
result := FADOTable.Fields.Count;
End;
Function TEzADOXTable.FieldDec( FieldNo: integer ): integer;
Var
Datatype: TFieldType;
Begin
Datatype := FADOTable.Fields[FieldNo - 1].Datatype;
If Datatype In ftNonTexttypes Then
Result := 0
Else
Case Datatype Of
ftstring{$IFDEF LEVEL4}, ftFixedChar,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -