Visual Basic 6 Database How-To

Previous chapterNext chapterContents


- B -
DATA ACCESS OBJECT REFERENCE



The Data Access Object (DAO) model provides you with an object-oriented interface to all the data manipulation techniques inherent in Microsoft Jet Database files. Figure B.1 shows the entire DAO object model in its hierarchical form.

Figure B.1. The Data Access Object model.

This appendix is designed as a reference to all the objects included in the DAO object model. The collections and objects are listed in alphabetical order with tables indicating and describing all the available methods and properties available to each.

Containers Collection, Container Object

The Containers collection contains all the Container objects that are part of a database. A container name can be Database, Tables, or Relations. Table B.1 shows the method of the Containers collection; Table B.2 shows its property. Table B.3 lists the properties of the Container object.

Table B.1. Containers collection method.

METHOD DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.2. Containers collection property.

PROPERTY DESCRIPTION
Count The number of objects in the collection

Table B.3. Container object properties.

PROPERTY DESCRIPTION
AllPermissions Returns all permissions for the user named by UserName, including those that are inherited from the user's group as well as the user's specific permissions
Inherit Sets or returns a value that indicates whether the document will receive a default Permissions property setting
Name Sets a user-defined name for the DAO object
Owner Sets the owner of the current Container object
Permissions Sets the permissions available for the user, of the current Container object, named by UserName
UserName Indicates the name of the user for the current Container object

Databases Collection, Database Object

The Database object is a member of the Databases collection. The Database object is a means of access to an open database file. Table B.4 shows the method of the Databases collection; Table B.5 shows its property. Table B.6 lists the methods of the Database object, and Table B.7 lists the properties.

Table B.4. Databases collection method.

METHOD DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.5. Databases collection property.

PROPERTY DESCRIPTION
Count Returns the number of objects in the collection

Table B.6. Database object methods.

METHOD DESCRIPTION
Close Closes the current Database object
Creates a new Property object
Creates a new QueryDef object and adds it to the QueryDefs collection
CreateRelation Creates a new Relation object and adds it to the Relations collection
CreateTableDef Creates a new TableDef object and adds it to the TableDefs collection
Execute Executes the specified SQL action query
MakeReplica Makes a new replica from another database replica
NewPassword Assigns a new password to the Database object
OpenRecordset Creates a new Recordset object and adds it to the Recordsets collection
PopulatePartial Synchronizes changes in a partial replica with the full replica and repopulates the partial replica based on the current replica filters
Synchronize Synchronizes two replicas

Table B.7. Database object properties.

PROPERTY DESCRIPTION
CollatingOrder Returns the sequence of the sort order in text and string comparison
Connect Returns information about the source
Connection Returns a connection object corresponding to the current Database object
Name Sets a user-defined name for the DAO object
QueryTimeout Indicates the number of seconds to wait until an error is reported when executing a query
RecordsAffected Indicates the number of records that were affected by the last call of the Execute method
Replicable Indicates whether the current Database object can be replicated
ReplicaID Returns a 16-byte value that uniquely identifies a database replica
Transactions Indicates whether an object supports transactions
Updatable Indicates whether an object can be updated
V1xNullBehavior Indicates whether zero-length strings in Text or Memo fields are converted to NULL values
Version Indicates the DAO version currently in use

Documents Collection, Document Object

The Documents collection contains all the Document objects for a specific type of Microsoft Jet Database object (Database, Table or Query, or Relationship). Table B.8 shows the method of the Documents collection, and Table B.9 shows its property. Table B.10 shows the Document object method; Table B.11 lists its properties.

Table B.8. Documents collection method.

METHOD DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.9. Documents collection property.

PROPERTY DESCRIPTION
Count Returns the number of objects in the collection

Table B.10. Document object methods.

METHOD DESCRIPTION
CreateProperty Creates a new user-defined Property object

Table B.11. Document object properties.

PROPERTY DESCRIPTION
AllPermissions Indicates all the permissions belonging to the current user of the document that are specific as well as inherited from its group
Container Returns the name of the Container object to which the current Document object belongs
DateCreated Returns the date and time the current object was created
LastUpdated Returns the date and time the current object was last modified
KeepLocal Indicates that the current object is not to be replicated
Name Sets a user-defined name for the DAO object
Owner Returns the user that is considered the owner of the current Document object
Permissions Returns the permissions specific to the current user of the document
Replicable Indicates whether the current Document object can be replicated
UserName Returns the name of the current user of the document

DBEngine Object

DBEngine is the only part of the DAO object model that is not a collection; rather it is only an object that contains and controls all the other components of the DAO object model. Table B.12 lists the methods of the DBEngine object; Table B.13 lists the properties.

Table B.12. DBEngine object methods.

METHOD DESCRIPTION
BeginTrans Begins transaction for the database engine
CommitTrans Commits changes since the last call to the BeginTrans method
Rollback Rolls back to the state before the call to the BeginTrans method
CompactDatabase Compacts an existing database into a new database
CreateDatabase Creates a new Database object, saves it to disk, and returns the opened Database object
CreateWorkspace Creates a new Workspace object and appends it to the Workspaces collection
Idle Allows the Jet engine to complete any pending tasks by suspending data processing
OpenConnection Opens a connection to an ODBC data source
OpenDatabase Opens a database and returns a Database object that represents it
RegisterDatabase Enters connection information for an ODBC data source in the Windows Registry
RepairDatabase Tries to repair a corrupt Jet database
SetOption Temporarily overrides values in the Windows Registry for the Microsoft Jet database engine

Table B.13. DBEngine object properties.

PROPERTY DESCRIPTION
DefaultType Sets the type of Workspace object to be used when the next Workspace object is created
DefaultUser Sets the username of the default Workspace object to be created
DefaultPassword Sets the password used to create the default Workspace object when it is initiated
IniPath Indicates the path of the information used from the Windows Registry about the Jet database engine
LoginTimeout Returns the number of seconds before an error occurs when attempting to log on to an ODBC data base
SystemDB Returns the path and name of the current workgroup information file
Version Indicates the DAO version currently in use

Errors Collection, Error Object

The Errors collection is a collection of Error objects pertaining to individual DAO operation failures. Table B.14 shows the Errors collection method, and Table B.15 shows its property. Table B.16 lists the properties of the Error object.

Table B.14. Errors collection method.

METHOD DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.15. Errors collection property.

PROPERTY DESCRIPTION
Count Returns the number of objects in the collection

Table B.16. Error object properties.

PROPERTY DESCRIPTION
Description Indicates the description of the current error
HelpContext Returns the context ID for a topic in a Windows Help file
HelpFile Returns the name of a Windows Help file
Number Indicates the number referring to the current error
Source Indicates the source of the current error

Fields Collection, Field Object

The Fields collection belongs to the Index, QueryDef, Relation, and TableDef objects. The collection is composed of all the Field objects of the corresponding object. The Field object is used to access the value of that field and its definition. Table B.17 lists the methods of the Fields collection, and Table B.18 shows its property. Table B.19 lists the Field object's methods, and Table B.20 lists its properties.

Table B.17. Fields collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.18. Fields collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.19. Field object methods.

METHOD DESCRIPTION
AppendChunk Appends a string to a Memo or Long Binary field
CreateProperty Creates a new user-defined Property object
GetChunk Returns a portion of a Memo or Long Binary field

Table B.20. Field object properties.

PROPERTY DESCRIPTION
AllowZeroLength Indicates whether a zero-length value can be stored in the field
Attributes Returns information containing characteristics of an object
CollatingOrder Returns the sequence of the sort order in text and string comparison
DataUpdatable Indicates whether the object's data can be updated
DefaultValue Returns a default value given to the field if no other value is specified
FieldSize Indicates the number of bytes used in the database for a Memo or Long Binary field
ForeignName Returns the name of a Field object in a foreign table that corresponds to a field in a primary table for a relationship
Name Sets a user-defined name for the DAO object
OrdinalPosition Indicates a numbered position of the current field in the Fields collection
OriginalValue Returns the value of the field when the last batch update began
Required Indicates whether the field must be given a value
Size Returns the size in length of the field
SourceField Indicates the name of the field that is the original source of the data for the current Field object
SourceTable Sets the name of the table that is the original source of the data for a Field object
Type Returns the operational type of object
ValidateOnSet Indicates whether a Field object value is indicated when its Value property is set
ValidationRule Returns the value that validates data in a field as it is changed or added to a table
ValidationText Indicates the message that your application displays if the value of the Field object does not satisfy the validation rule
Value Returns the actual data stored in the field
VisibleValue Returns the value that is newer than the OriginalValue property as determined by a batch update conflict

Groups Collection, Group Object

The Groups collection contains Group objects of a workspace or user. A Group object is a group of users who have common access permissions. Table B.21 lists the methods of the Groups collection, and Table B.22 shows its property. Table B.23 shows the Group object's method, and Table B.24 lists its properties.

Table B.21. Groups collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.22. Groups collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.23. Group object method.

METHOD DESCRIPTION
CreateUser Creates a new user object for the current group

Table B.24. Group object properties.

PROPERTY DESCRIPTION
Name Sets a user-defined name for the DAO object
PID Returns a group personal identifier

Indexes Collection, Index Object

The Indexes collection contains all the Index objects pertaining to a particular TableDef object. The Index object specifies the order of the records in a table. Table B.25 lists the Indexes collection methods, and Table B.26 shows the Indexes collection property. Table B.27 lists the Index object methods, and Table B.28 lists the Index object properties.

Table B.25. Indexes collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.26. Indexes collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.27. Index object methods.

METHOD DESCRIPTION
CreateField Creates a Field object and appends it to the Fields collection
CreateProperty Creates a Property object

Table B.28. Index object properties.

PROPERTY DESCRIPTION
Clustered Indicates whether the Index object is a clustered index
DistinctCount Indicates the number of unique values for the Index object
Foreign Indicates whether the current Index object represents a foreign key
IgnoreNulls Indicates whether NULL values in the fields of the current Index object are allowed
Name Sets a user-defined name for the DAO object
Primary Indicates that the current index is the primary key
Required Indicates that the values of the Field objects that make up the current Index object must be specified
Unique Indicates that the combination of the Field object values that make up the current Index object are unique

Parameters Collection, Parameter Object

The Parameters collection contains all the Parameter objects of a QueryDef object. A Parameter object contains a value that is passed to a QueryDef object. Table B.29 shows the Parameters collection method, and Table B.30 shows its property. Table B.31 lists the Parameter object properties.

Table B.29. Parameters collection method.

METHOD DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.30. Parameters collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.31. Parameter object properties.

PROPERTY DESCRIPTION
Direction Indicates whether the object represents an input, an output, both, or the return value from the procedure
Name Sets a user-defined name for the DAO object
Type Indicates the operational type of object
Value Sets the value of the Parameter object

QueryDefs Collection, QueryDef Object

The QueryDefs collection holds all QueryDef objects for a database. The QueryDef object is a stored definition of a query in a Jet database file or a temporary definition in an ODBCDirect workspace. Table B.32 lists the methods of the QueryDefs collection, and Table B.33 shows its property. Table B.34 lists the methods of the QueryDef object, and Table B.35 lists its properties.

Table B.32. QueryDefs collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.33. QueryDefs collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.34. QueryDef object methods.

METHOD DESCRIPTION
Cancel Cancels execution of an asynchronous method call
Close Closes the current recordset
CreateProperty Creates a new user-defined Property object
Execute Executes the current query definition
OpenRecordset Creates a new Recordset object and appends it to the Recordsets collection

Table B.35. QueryDef object properties.

DESCRIPTION
CacheSize Returns the number of locally cached records that will be received from an ODBC data source
Connect Indicates the information about the source of an open connection
DateCreated Returns the date and time the current object was created
LastUpdated Returns the date and time the current object was last modified
KeepLocal Indicates that the current object is not to be replicated
LogMessages Indicates whether messages from an ODBC data source are recorded
MaxRecords Indicates the maximum return from the query
Name Sets a user-defined name for the DAO object
ODBCTimeout Returns a number, indicating the number of seconds to wait before a timeout error occurs when a QueryDef is executed on an ODBC database
Prepare Indicates whether the query should be prepared on the server as a temporary stored procedure
RecordsAffected Indicates the number of records affected by the last call to the Execute method
Replicable Indicates whether the current object can be replicated
ReturnsRecords Indicates whether a SQL pass-through query returns records
SQL Sets the SQL statement that composes the current query
StillExecuting Indicates whether an asynchronous operation has finished executing
Type Returns the operational type of object
Updatable Indicates whether the QueryDef object can be updated

Recordsets Collection, Recordset Object

The Recordsets collection contains all open Recordset objects of a database. Through the Recordset object, data can be manipulated and accessed. Recordset types include Table, Dynaset, Snapshot, Forward-only, and Dynamic. All recordsets are accessed by rows (records) and columns (fields). Table B.36 shows the method of the Recordsets collection, and Table B.37 shows its property. Table B.38 lists the methods of the Recordset object, and Table B.39 lists its properties.

Table B.36. Recordsets collection method.

DESCRIPTION
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.37. Recordsets collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.38. Recordset object methods.

METHOD DESCRIPTION
AddNew Adds a new record to the current recordset
Cancel Cancels operation of an asynchronous operation
CancelUpdate Cancels any pending updates
Clone Creates a duplicate of the current Recordset object
Close Closes the current recordset
CopyQueryDef Returns a QueryDef object that is a copy of the QueryDef used to create the current Recordset object
Delete Deletes the current record
Edit Prepares the current record for editing by Visual Basic code
FillCache Fills all or part of a Recordset object that contains data from an ODBC data source
FindFirst Finds the first record that matches specified criteria
FindLast Finds the last record that matches specified criteria
FindNext Finds the next record that matches specified criteria
FindPrevious Finds the previous record that matches specified criteria
GetRows Returns multiple rows from the current Recordset object
Move Moves the position of the current record in the current Recordset object
MoveFirst Moves to the first record of the recordset
MoveLast Moves to the last record of the recordset
MoveNext Moves to the next record of the recordset
MovePrevious Moves to the previous record of the recordset
NextRecordset Returns the next set of records returned by a multipart selection query in an OpenRecordset call
OpenRecordset Sets the recordset to a new selection of records
Requery Performs the specified query again to update the recordset with the current database information
Seek Finds a match to a specific criteria by using an index of the current recordset
Update Saves changes specified to the recordset from the AddNew or Edit method

Table B.39. Recordset object properties.

PROPERTY DESCRIPTION
AbsolutePosition Sets the record pointer position within the Recordset object
BatchCollisionCount Indicates the number of records that did not complete the last batch update
BatchCollisions Returns an array of bookmarks indicating which rows generated collisions in the last batch update operation
BatchSize Indicates the number of statements sent back to the server in each batch
BOF Returns the beginning-of-file indicator
EOF Returns the end-of-file indicator
Bookmark Returns the bookmark for a record position
Bookmarkable Returns a Boolean stating the capability to create bookmarks
CacheSize Indicates the number of locally cached records that will be received from an ODBC data source
CacheStart Returns a bookmark to the first record in a Recordset object containing data to be locally cached from an ODBC data source
Connection Sets the Connection object that owns the current Recordset object
DateCreated Returns the date and time the current object was created
LastUpdated Returns the date and time the current object was last modified
EditMode Indicates the state of editing for the current record
Filter Sets a filter to determine the records included in a subsequently opened Recordset object
Index Sets the current index for the Recordset object
LastModified Returns a bookmark to the last edited or new record of the current Recordset object
LockEdits Indicates the type of locking that is in effect while editing
Name Sets a user-defined name for the DAO object
NoMatch Indicates whether a record was found after using either the Seek method or a Find method
PercentPosition Returns an approximate percentage of the current record position as compared to the entire record population of the current Recordset object
RecordCount Indicates the number of records in the current Recordset object
RecordStatus Returns the update status of a current record that is part of a batch update
Restartable Indicates whether the current object supports the ReQuery method
Sort Sets the order for records in the current Recordset object
StillExecuting Indicates whether an asynchronous operation has finished
Transactions Indicates whether the object supports transactions
Type Indicates the operational type of the object
Updatable Indicates whether the current object can be updated
UpdateOptions Indicates the way in which batch updates are executed
ValidationRule Returns the value that validates data in a field as it is changed or added to a table
ValidationText Sets a message that your application displays if the value of the Field object does not satisfy the validation rule

Relations Collection, Relation Object

The Relations collection contains all the Relation objects stored in a database. A Relation object indicates the relationship between fields and tables or queries of a Jet database. Table B.40 lists the methods of the Relations collection, and Table B.41 shows its property. Table B.42 shows the method of the Relation object, and Table B.43 lists its properties.

Table B.40. Relations collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.41. Relations collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.42. Relation object method.

METHOD DESCRIPTION
CreateField Creates a Field object and appends it to the Fields collection

Table B.43. Relation object properties.

PROPERTY DESCRIPTION
Attributes Returns characteristics of the current Relation object
ForeignTable Sets the name of the current Relation object's foreign table
Name Sets a user-defined name for the DAO object
PartialReplica Indicates whether the Relation object should be included in a partial replica
Table Returns the name of the current Relation object's primary table
ValidationText Sets a message that your application displays if the value of the Field object does not satisfy the validation rule

TableDefs Collection, TableDef Object

The TableDefs collection contains all TableDef objects for a given database. The TableDef object is used to access and manipulate a tables definition. Table B.44 lists the methods of the TableDefs collection, and Table B.45 shows its property. Table B.46 lists the methods of the TableDef object, and Table B.47 lists its properties.

Table B.44. TableDefs collection methods.

METHOD DESCRIPTION
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.45. TableDefs collection property.

PROPERTY DESCRIPTION
Count Indicates the number of objects in the collection

Table B.46. TableDef object methods.

METHOD DESCRIPTION
CreateField Creates a new Field object for the current TableDef and appends it to the Fields collection
CreateIndex Creates a new Index object for the current TableDef object and appends it to the Indexes collection
CreateProperty Creates a new user-defined Property object for the current TableDef object
OpenRecordset Creates a new Recordset object and appends it to the Recordsets collection

RefreshLink Updates the connection information for a linked table

Table B.47. TableDef object properties.

PROPERTY DESCRIPTION
Attributes Indicates the characteristics of the current TableDef object
ConflictTable Returns the name of a conflict table containing the database records that conflicted during the synchronization of two replicas
Connect Sets information about the source of an open connection
DateCreated Returns the date and time the current object was created
LastUpdated Returns the date and time the current object was last modified
KeepLocal Indicates that the object is not to be replicated with replication of the database
Name Sets a user-defined name for the DAO object
RecordCount Indicates the number of records in a table
Replicable Indicates whether the object is replicable
ReplicaFilter Indicates what subset of records is replicated from a full replica
SourceTableName Indicates the name of a linked table or the name of a base table
Updatable Indicates whether you can change the DAO object
ValidationRule Sets a value that validates data in a field as it is changed or added to a table
ValidationText Sets a message that your application displays if the value of the Field object does not satisfy the validation rule

Workspaces Collection, Workspace Object

The Workspaces collection contains all active Workspace objects that are not hidden. A Workspace object defines how the Visual Basic application interacts with data. Table B.48 lists the methods of the Workspaces collection, and Table B.49 shows its property. Table B.50 lists the methods of the Workspace object, and Table B.51 lists its properties.

Table B.48. Workspaces collection methods.

METHOD Description
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.49. Workspaces collection property.

PROPERTY Description
Count Indicates the number of objects in the collection

Table B.50. Workspace object methods.

METHOD Description
BeginTrans Begins transaction for the workspace
CommitTrans Commits changes since the last call to the BeginTrans method
Rollback Rolls back to the workspace state before the call to the BeginTrans method
Close Closes the Workspace object
CreateDatabase Creates a new Database object
CreateGroup Creates a new Group object
CreateUser Creates a new User object
OpenConnection Opens a connection object for an ODBC data source
OpenDatabase Opens a database with the current workspace

Table B.51. Workspace object properties.

PROPERTY Description
DefaultCursorDriver Returns the type of cursor driver used on the connection created by the call to OpenConnection or OpenDatabase
IsolateODBCTrans Indicates whether multiple transactions that involve the same Jet-connected ODBC data source are isolated
LoginTimeout Indicates the number of seconds before an error occurs while attempting to log on to an ODBC database
Name Sets a user-defined name for the DAO object
Type Indicates the operational type of object
UserName Returns the owner of the current workspace object

Users Collection, User Object

A Users collection contains all User objects belonging to a particular Workspace or Group object. The User object refers to a specific user account with various permissions. Table B.52 lists the methods of the Users collection, and Table B.53 shows its property. Table B.54 lists the methods of the User object, and Table B.55 lists its properties.

Table B.52. Users collection methods.

METHOD Description
Append Adds a new object to the collection
Delete Removes an object from the collection
Refresh Updates the contents of the collection to reflect the current status of the database

Table B.53. Users collection property.

PROPERTY Description
Count Indicates the number of objects in the collection

Table B.54. User object methods.

METHOD Description
CreateGroup Creates a new Group object for the current user
NewPassword Changes the password of the current user

Table B.55. User object properties.

PROPERTY Description
Name Sets the name of the current User object
Password Sets the password for the current User object
PID Returns a personal identifier for the current User object


Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.