49
Visual Basic 6 Black Book:Working With Database Objects In Code
Here are the possible settings for options:
• dbAppendOnly—Allows users to append new records to the Recordset but prevents them from
editing or deleting existing records (Microsoft Jet dynaset-type Recordset only).
• dbSQLPassThrough—Passes an SQL statement to a Microsoft Jet-connected ODBC data source
for processing (Jet snapshot-type Recordset only).
• dbSeeChanges—Generates a runtime error if one user is changing data that another user is editing
(Jet dynaset-type Recordset only).
• dbDenyWrite—Prevents other users from modifying or adding records (Jet Recordset objects
only).
• dbDenyRead—Prevents other users from reading data in a table (Jet table-type Recordset only).
• dbForwardOnly—Creates a forward-only Recordset (Jet snapshot-type Recordset only). It is
provided only for backward compatibility, and you should use the dbOpenForwardOnly constant in
the type argument instead of using this option.
• dbReadOnly—Prevents users from making changes to the Recordset (Microsoft Jet only). The
dbReadOnly constant in the lockedits argument replaces this option, which is provided only for
backward compatibility.
• dbRunAsync—Runs an asynchronous query (ODBCDirect workspaces only).
• dbExecDirect—Runs a query by skipping SQLPrepare and directly calling SQLExecDirect
(ODBCDirect workspaces only).
• dbInconsistent—Allows inconsistent updates (Microsoft Jet dynaset-type and snapshot-type
Recordset objects only).
• dbConsistent—Allows only consistent updates (Microsoft Jet dynaset-type and snapshot-type
Recordset objects only).
Here are the possible settings for the lockedits argument:
• dbReadOnly—Prevents users from making changes to the Recordset (default for ODBCDirect
workspaces).
• dbPessimistic—Uses pessimistic locking to determine how changes are made to the Recordset in a
multiuser environment.
• dbOptimistic—Uses optimistic locking to determine how changes are made to the Recordset in a
multiuser environment.
• dbOptimisticValue—Uses optimistic concurrency based on row values (ODBCDirect workspaces
only).
• dbOptimisticBatch—Enables batch optimistic updating (ODBCDirect workspaces only).
Let’s see an example to make this clearer. In the previous few topics, we’ve developed a TableDef object, td ,
in our DAO code example, the daocode project. To append that object to the Database object we created, db,
we use the Append method of the database object’s TableDefs collection. After installing the table, we open
it for use with the Database object’s OpenRecordset method this way, creating a new DAO Recordset,
which we name dbrecordset:
Sub CreateTable()
Set td = db.CreateTableDef(TableForm.Text1.Text)
Set fields(0) = td.CreateField(TableForm.Text2.Text, dbText)
Set fields(1) = td.CreateField(TableForm.Text3.Text, dbText)
td.fields.Append fields(0)
td.fields.Append fields(1)
Set dbindex = td.CreateIndex(TableForm.Text2.Text + "index")
Set IxFlds = dbindex.CreateField(TableForm.Text2.Text)
dbindex.fields.Append IxFlds
file:///E|/Program%20Files/KaZaA/My%20Shared%...Basic%20-%20%20Black%20Book/ch25/863-865.html (2 of 3) [7/31/2001 9:05:04 AM]