Home > Language Reference > Classes > GenericDB
Record Property
Accesses a record in a database.
Syntax
Public Property Get Record(ByVal lIndex As Long) As StreamRecord
Public Property Set Record(ByVal lIndex As Long, ByRef objStream As StreamRecord)
| Parameter | Description |
| lIndex | Record index |
| objStream | Reference to a StreamRecord object type. |
Remarks
This property gives access to the record at the index specified in the lIndex parameter. The StreamRecord class manipulates records in a database.
In the following example, we add all the records from the address book database into a list :
Private Sub Button1_Click()
dim db as new RecordDB
dim rec as new StreamRecord
dim sz as String, i as Integer
dim di as new DatabaseInfo
If not di.FindByName("AddressDB") then Exit Sub
db.OpenByName "AddressDB",hbModeOpenExisting+hbModeReadWrite,"data","addr"
for i=0 to db.RecordCount-1
set rec=db.Record(i)
If Not rec Is Nothing Then
rec.Position=9 'move to name offset
rec.Read sz
List1.AddItem sz
End If
Next i
db.Close
End subIn the following example, we create a database, in which 10 records made up of an integer and a string are added. Then, we step through the database reading each record and adding the values read to a list:
Private Sub Button1_Click()
dim db as new RecordDB
dim rec as new StreamRecord
Dim i as Integer
dim OneInteger as Integer
Dim OneString as String
db.OpenByName "TestDB",hbModeCreateAlways+hbModeReadWrite,"data","ZZZZ"
'Add records
For i=0 to 9
rec.Clear
rec.Write i
rec.Write " item " & Cstr(i)
db.NewRecord rec
Next i
'Now Read records
For i=0 to 9
set rec=db.Record(i)
rec.Read OneInteger
rec.Read OneString
List1.AddItem OneInteger & " : " & OneString
Next i
db.Close
End Sub
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |