Class

DatabaseRecord


Warning

This item was deprecated in version 2019r2. Please use DatabaseRow as a replacement.

Description

Used to create new Database records (rows). The methods are used to populate the fields in a record (row). Call it once per column.

Methods

Name

Parameters

Returns

Shared

BlobColumn

Name As String

String

Name As String

Assigns value As String

BooleanColumn

Name As String

Boolean

Name As String

Assigns value As Currency

Column

Name As String

String

Name As String

Assigns value As String

index As Integer

String

CurrencyColumn

Name As String

String

Name As String

Assigns value As Currency

DateColumn

Name As String

Date

Name As String

Assigns value As Currency

DoubleColumn

Name As String

Double

Name As String

Assigns value As Double

FieldCount

Integer

FieldName

idx As Integer

String

FieldType

idx As Integer

Integer

Int64Column

Name As String

Int64

Name As String

Assigns value As Int64

IntegerColumn

Name As String

Integer

Name As String

Assigns value As Integer

PictureColumn

Name As String

Picture

Name As String

Assigns value As Picture/api/graphics/picture>

Name As String

format As String = Picture.FormatPNG/api/graphics/picture>, quality As Integer = Picture.QualityDefault, Assigns value As Picture

Method descriptions


DatabaseRecord.BlobColumn

BlobColumn(Name As String) As String

Gets the blob value for the specified field. The parameter is the column name. Use BLOB columns to work with binary data such as pictures or files.


DatabaseRecord.BlobColumn

BlobColumn(Name As String, Assigns value As String)

Sets the specified field to the specified BLOB. The parameter is the column name. Use BLOB columns to work with binary data such as pictures or files.


DatabaseRecord.BooleanColumn

BooleanColumn(Name As String) As Boolean

Gets the Boolean value for the column Name.


DatabaseRecord.BooleanColumn

BooleanColumn(Name As String, Assigns value As Boolean)

Sets the Boolean value for the column Name.


DatabaseRecord.Column

Column(Name As String) As String

Gets the String value for the column at position Index. The first index is 1.


DatabaseRecord.Column

Column(Name As String, Assigns value As String)

Gets the String value for the column at position Index. The first index is 1.


DatabaseRecord.Column

Column(Index As Integer) As String

Gets the String value for the column at position Index. The first index is 1.

Creates a new row in the team table:

Dim row As New DatabaseRecord

row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"

myDB.InsertRecord("Team", row)

If myDB.Error Then
  MsgBox("DB Error: " + myDB.ErrorMessage)
End If

DatabaseRecord.CurrencyColumn

CurrencyColumn(Name As String) As Currency

Gets the Currency value for the column Name.


DatabaseRecord.CurrencyColumn

CurrencyColumn(Name As String, Assigns value As Currency)

Sets the Currency value for the column Name.


DatabaseRecord.DateColumn

DateColumn(Name As String) As Date

Gets the Date value for the column Name.


DatabaseRecord.DateColumn

DateColumn(Name As String, Assigns value As Date)

Sets the Date value for the column Name.


DatabaseRecord.DoubleColumn

DoubleColumn(Name As String) As Double

Gets the Double value for the column Name.


DatabaseRecord.DoubleColumn

DoubleColumn(Name As String, Assigns value As Double)

Sets the Double value for the column Name.


DatabaseRecord.FieldCount

FieldCount As Integer

Returns the number of fields in the DatabaseRecord.

Creates a new row in the team table:

Dim row As New DatabaseRecord

row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"

myDB.InsertRecord("Team", row)

If myDB.Error Then
  MsgBox("DB Error: " + myDB.ErrorMessage)
Else
  MsgBox("Fields added: " + Str(row.FieldCount)
End If

DatabaseRecord.FieldName

FieldName(idx As Integer) As String

Returns the name of the field in the DatabaseRecord specified by idx. The fields are in a 0-based array.

Creates a new row in the team table:

Dim row As New DatabaseRecord

row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"

myDB.InsertRecord("Team", row)

If myDB.Error Then
  MsgBox("DB Error: " + myDB.ErrorMessage)
Else
  MsgBox("Field 2 Name: " + row.FieldName(1))
End If

DatabaseRecord.FieldType

FieldType(idx As Integer) As Integer

Returns the type of the field in the DatabaseRecord specified by idx. The fields are in a 0-based array. The field type codes are the same as those returned by FieldSchema.

This example displays the field type of the third field in the DatabaseRecord rec.

MsgBox(Str(rec.FieldType(2)))

DatabaseRecord.Int64Column

Int64Column(Name As String) As Int64

Gets the Int64 value for the column Name.


DatabaseRecord.Int64Column

Int64Column(Name As String, Assigns value As Int64)

Sets the Int64 value for the column Name.


DatabaseRecord.IntegerColumn

IntegerColumn(Name As String) As Integer

Gets the Integer value for the column Name.


DatabaseRecord.IntegerColumn

IntegerColumn(Name As String, Assigns value As Integer)

Sets the Integer value for the column Name.


DatabaseRecord.PictureColumn

PictureColumn(Name As String) As Picture

Sets the Picture value for the column Name with the specified format and quality.


DatabaseRecord.PictureColumn

PictureColumn(Name As String, Assigns value As Picture)

Sets the Picture value for the column Name with the specified format and quality.


DatabaseRecord.PictureColumn

PictureColumn(Name As String, format As String, quality As Integer = Picture.QualityDefault, Assigns value As Picture)

Sets the Picture value for the column Name with the specified format and quality.

For most databases using the BlobColumn method is preferred.

Creates a new row in the team table:

Dim row As New DatabaseRecord

row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"
row.PictureColumn("Logo") = Canvas1.Backdrop

myDB.InsertRecord("Team", row)

If myDB.Error Then
  MsgBox("DB Error: " + myDB.ErrorMessage)
End If

Notes

Assignments via the DateColumn method store the time as well as the date to support the SQL TimeStamp and Time field types (as well as Date). Note that if the date part is January 1, 0001, then this is converted to SQL as only a time (e.g., "18:54:00"), whereas if the date is anything else, it converts to SQL in full form (e.g., "2000-5-30 18:54:00").

Not all field types supported by the DatabaseRecord class are supported by all data sources. Check whether your data source supports the data type returned by the method you are using.

Use the BlobColumn method to save binary data (such as pictures or files) to the table.

Sample code

Creates a new row in the team table:

Dim row As New DatabaseRecord

row.Column("Name") = "Penguins"
row.Column("Coach") = "Bob Roberts"
row.Column("City") = "Boston"

myDB.InsertRecord("Team", row)

If myDB.Error Then
  MsgBox("DB Error: " + myDB.ErrorMessage)
End If

Compatibility

All project types on all supported operating systems.