The class represents a DB field in an (existing) DB table. You cannot create the class. All properties can only be read. The class has neither methods nor events.
The Field class has the following five properties:
Property | Data type | Description |
---|---|---|
Collation | String | Provides information on the sorting of the DB field. |
Name | String | Delivers the name of the DB field. |
Table | Table | Delivers the table object that contains this DB field. |
Type | Integer | Delivers the type of a DB field. One of the following constants for the field data type is returned: db.Blob (-2), db.Boolean (1), db.Date (8), db.Float (7), db.Integer (4), db.Long (5), db.Serial (-1) and db.String (9). |
Length | Integer | Returns the maximum length of a field. This only applies to text fields. You can determine the type of a DB field via the `Field.Type` property. If no limit has been specified for the DB text field, 0 is returned. |
Table 22.4.7.1.1 : Properties of the Field class
Example
Dim hCollection As Collection Dim hTable As Table, hField As Field hCollection = ["-2": "db.Blob", "-1": "db.Serial", "1": "db.Boolean", "4": "db.Integer", "5": "db.Long", "7": "db.Float", "8": "db.Date", "9": "db.String"] If DBCS.DBConnection.Tables.Exist("members") Then '-- The existing DB table `members` becomes the current DB table hTable = DBCS.DBConnection.Tables["members"] Print "DBTableName: "; hTable.Name Print "---------------------------------------" Print For Each hField In hTable.Fields Print "DBField-Name: "; hField.Name Print "--------------------------------------" Print "DBField-Collation: "; IIf(hField.Collation = Null, " Not specified", hField.Collation) Print "DBField-Standardwert: "; IIf(hField.Default = Null, " Not specified", hField.Default) Print "DBField-Typ: "; hCollection[hField.Type] If hField.Type = db.String Then If hField.Length = 0 Then Print "DBField length: No limit specified." Else Print "DBField length: "; hField.Length Endif Endif Print Next Endif
This output is in the console of the IDE:
DBTableName: members --------------------------------------- DBField-Name: m_id -------------------------------------- DBField-Collation: Not specified DBField-Standard-Value: Not specified DBField-Type: db.Serial DBField-Name: lastname -------------------------------------- DBField-Collation: Not specified DBField-Standard-Value: Not specified DBField-Type: db.String DBField length: No limit specified DBField-Name: date -------------------------------------- DBField-Collation: Not specified DBField-Standard-Value: Not specified DBField-Type: db.Date DBField-Name: description -------------------------------------- DBField-Collation: Not specified DBField-Standard-Value: Not specified DBField-Type: db.String DBField length: No limit specified