VB-UNIT III-Data Access Options' With You
VB-UNIT III-Data Access Options' With You
UNIT – III
ODBC AND DATA ACCESS OBJECTS
• DBEngine
• Workspace
• Database
• TableDef
• Field
• Index
• Recordset Objects.
The DBEngine
- Is the top-level database object and corresponds to the Jet database engine.
- This object Used to set database engine system parameters and default
workspace.
The Workspace
The Database
The QueryDef
The Recordset
- is a stored index associated with Table Def Object or table type Recorset Object
- setting the index allows the user to quickly re-order the records in a table.
The Parameter Object
- The users collection contains all stored User objects of a Workspce or group
account.
A Group
- Each user in the group inherits the permissions to access the objects that the
group can access.
A Relation Object
A Property Object
A Container Object
- holds information describing the objects that are grouped into that container.
- In order to work with data access objects, a reference has to be set to the
appropriate DAO library. There are 2 DAO libraries supported by VB 6.0. They
are
To set reference to the DAO type library the following sequence has to be
followed:
- Click on OK
Opening a Database
Syntax:
OpenDatabase(dbname, [options],[readonly],[connect])
Dim db as Database
Set db = OpenDatabase(“emloyee_details”)
db- is a variable that represents the Database object. Specify the database for
exclusive use,
- It is a set of records that represents a single table which can be used to add,
change or delete records.
- It cannot be updated and does not reflect any changes made by the users.
- This type represents a query result set from one or more base tables in which we
can add, change, or delete records from a row-returning query.
Ex:
Dim rs as Recordset
Where
Navigating a Recordset
- After creating a Recordset object, various Move methods can be used to navigate
through the records in a Recordset.
- the Recordset object provides 2 properties to the user to know when he has
moved to the beginning or the end of the recordset.
- The EOF(End of File) property is True when the user moves beyond the
last record in the recordset.
- The BOF(Beginning of File) property is True when the user has moved to a
position before the first record in the recordset.
Edit Method – the user can edit the current record using the Edit method.
The update method is used to save the necessary changes made to the record.
Finding Records
FindFirst method – finds the first record satisfying the specified criteria.
FindLast method – finds the last record satisfying the specified criteria.
FindNext method – finds the next record satisfying the specified criteria,
searching forward from the current record.
- The Seek method can be used to locate a record in a table type Recordset.
- It performs an indexed search for the first occurrence of the record that matches
the indexed criteria.
- A value must be supplied for the parameter in order to run the query.
TableDef Data Object
- New fields can be added or existing fields can be deleted using the Append or
Delete methods respectively on the Tabledef object.
Syntax
- The data entered in the table should match the order of the columns as they
appear in the table.