Represents the entire set of records from a base table or the results of an executed command.
At any time, this object refers only to a single record within the set as the current record. This object must be associated with a valid connection object or have a valid connection string assigned to it before any other methods or properties are called or set.
Indicates which Connection object the Recordset object currently belongs to.
object.ActiveConnection
String. Sets or returns a String containing the definition for a connection or a Connection object. Default is a NULL object reference.
Read/write.
The format of the connection string is similar to an ODBC connection string. For example: DBType=0;Database=MyServer-TCP.World;UID=Scott;PWD=Tiger
DBType - The valid types are 0 for an Oracle 8 database or 1 for a B2System SQLIntegrator database. Database - Any valid database name that corresponds to the database type specified by DBType. UID - A valid user ID for the database. PWD - A valid password for the user ID and database.
Indicates that the current record position is after the last record in a Recordset object.
object.Eof
Boolean.
Read-only.
A collection of Field objects that correspond to the fields held by the current Recordset object.
object.Fields
Fields
Read-only.
Indicates the data source for a Recordset object.
Object.Source
String.
Read-only.
Closes an open Recordset object and any dependent objects.
object.Close()
None.
None.
Moves to the next record in a specified Recordset object and makes that record the current record.
object.MoveNext()
None.
None.
Opens a Recordset object.
object.Open(
Source As Variant,
ActiveConnection As Variant or String,
CursorType As CursorTypeEnum,
LockType As LockTypeEnum)
Evaluates to a valid Command object, an SQL statement, a table name, or a stored procedure call. (Currently supports only SQL statements or Command objects.)
Either a Variant that evaluates to a valid Connection object, or a String containing ConnectionString parameters. See the ConnectionString property for a description of the connection string format.
None.
If the ActiveConnection property used to open the Recordset is a connection string, the ActiveConnection object returned by the ActiveConnection property is valid only for the lifetime of the Recordset object. If the Recordset object is closed, the ActiveConnection is also closed.
This sample script prints details about all the departments.The sample does the following:
’This sample script for RecordSet object
Option VBA
On Error Resume Next
Set CN = CreateObject("UCX:NDODB.CONNECTION")
CN.Open ("DBTYPE=0;DATABASE=ORANW81.WORLD", "scott","Tiger")
Set RS = CN.Execute("Select * from dept", lRec)
If Err <> 0 Then
GoTo errorhandler
End If
DisplayRS (RS)’ Print the details about the recordset
’
Print RS.ActiveConnection
Print RS.Source
RS.Close
’Insert a new department
’
CN.Execute ("Insert into deptvalues(78,’Books’,’Boston’)",lRec)
RS.Requery
DisplayRS (RS)
CN.CommitTrans
CN.Close
RS.Close
’ Subroutine to display the details of a record set.
’
Sub DisplayRS(RS As Object)
Dim FLDS As Object
Dim FLD As Object
Dim RecValue As String
Dim FldCount As Long
Set FLDS = RS.Fields
RecValue = ""
For FldCount = 1 To FLDS.Count
Set FLD = FLDS.Item(FldCount)
RecValue = RecValue & " " & CStr(FLD.Name)
Next
Print RecValue
PrintLine (60)
Do
RecValue = ""
For FldCount = 1 To FLDS.Count
Set FLD = FLDS.Item(FldCount)
RecValue = RecValue & " " & CStr(FLD.Value)
Next
Print RecValue
RS.MoveNext
Loop While Not RS.EOF
End Sub
’Subroutine to print a line
’
Sub PrintLine(Number)
For PrintCount = 1 To Number
Line = Line & "-"
Next
Print Line
End Sub