荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: baty (新一代懒人), 信区: Database
标  题: 怎样用ADO打开一个带密码的Access库
发信站: BBS 荔园晨风站 (Mon Mar 12 22:15:36 2001), 转信

【 以下文字转载自 baty 的信箱 】
【 原文由 baty.bbs@argo.zsu.edu.cn 所发表 】
发信人: CMusic (音韵), 信区: Database
标  题: 怎样用ADO打开一个带密码的Access库
发信站: 逸仙时空 Yat-sen Channel (Wed Nov  1 00:20:47 2000), 站内信件

【 在 explorer (校长) 的大作中提到: 】
:    现有一ACCESS库reg.mdb,密码:1123,ODBC USER DNS:reg
:    由于缺乏相应的资料,不知该如何打开,请指教。
:    BTW:哪儿可以找到ADO的帮助文件。!!
:    Thank You For Your Help.

Creates a new Recordset object and appends it to the Recordsets
collection.

Syntax

For Connection and Database objects:

Set recordset = object.OpenRecordset (source, type, options,
lockedits)

For QueryDef, Recordset, and TableDef objects:

Set recordset = object.OpenRecordset (type, options, lockedits)

The OpenRecordset method syntax has these parts.

Part    Description
recordset       An object variable that represents the Recordset
object you wan
open.
object  An object variable that represents an existing object from which
 you
want to create the new Recordset.
source  A String specifying the source of the records for the new
Recordset.
The source can be a table name, a query name, or an SQL statement that
returns records. For table-type Recordset objects in Microsoft Jet
databases,
the source can only be a table name.
type    Optional. A constant that indicates the type of Recordset to
open, as
specified in Settings.
options Optional. A combination of constants that specify
characteristics of
the new Recordset, as listed in Settings.
lockedits       Optional. A constant that determines the locking for the
 Record
as specified in Settings.
Settings

You can use one of the following constants for the type argument.

Constant        Description


dbOpenTable     Opens a table-type Recordset object (Microsoft Jet
workspaces
only).
dbOpenDynamic   Opens a dynamic-type Recordset object, which is
similar to an
ODBC dynamic cursor. (ODBCDirect workspaces only)
dbOpenDynaset   Opens a dynaset-type Recordset object, which is
similar to an
ODBC keyset cursor.
dbOpenSnapshot  Opens a snapshot-type Recordset object, which is similar
 to an
ODBC static cursor.
dbOpenForwardOnly?Opens a forward-only-type Recordset object.
Note   If you open a Recordset in a Microsoft Jet workspace and you
don't
specify a type, OpenRecordset creates a table-type Recordset, if
possible. If
you specify a linked table or query, OpenRecordset creates a
dynaset-type
Recordset. In an ODBCDirect workspace, the default setting is
dbOpenForwardOnl
y.

You can use a combination of the following constants for the options
argument.

Constant        Description
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 (Microsoft Jet snapshot-type Recordset
only).
dbSeeChanges    Generates a run-time error if one user is changing
data that
another user is editing (Microsoft Jet dynaset-type Recordset only).
This is
useful in applications where multiple users have simultaneous
read/write
access to the same data.
dbDenyWrite?Prevents other users from modifying or adding records
(Microsoft
Jet Recordset objects only).
dbDenyRead?Prevents other users from reading data in a table
(Microsoft Jet
table-type Recordset only).
dbForwardOnly?Creates a forward-only Recordset (Microsoft 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). Use this option only when
you抮e
not opening a Recordset based on a parameter query. For more
information, see
the "Microsoft ODBC 3.0 Programmer抯 Reference."
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).
Note   The constants dbConsistent and dbInconsistent are mutually
exclusive,
and using both causes an error. Supplying a lockedits argument when
options
uses the dbReadOnly constant also causes an error.

You can use the following constants for the lockedits argument.

Constant        Description
dbReadOnly      Prevents users from making changes to the Recordset
(default fo
ODBCDirect workspaces). You can use dbReadOnly in either the options
argument
or the lockedits argument, but not both. If you use it for both
arguments, a
run-time error occurs.
dbPessimistic?Uses pessimistic locking to determine how changes are made
 to
the Recordset in a multiuser environment. The page containing the
record
you're editing is locked as soon as you use the Edit method (default
for
Microsoft Jet workspaces).
dbOptimistic?Uses optimistic locking to determine how changes are made
to the
Recordset in a multiuser environment. The page containing the record
is not
locked until the Update method is executed.
dbOptimisticValue?Uses optimistic concurrency based on row values
(ODBCDirect
workspaces only).
dbOptimisticBatch?Enables batch optimistic updating (ODBCDirect
workspaces
only).
Remarks

In a Microsoft Jet workspace, if object refers to a QueryDef object,
or a
dynaset- or snapshot-type Recordset, or if source refers to an SQL
statement
or a TableDef that represents a linked table, you can't use
dbOpenTable for
the type argument; if you do, a run-time error occurs. If you want to
use an
SQL pass-through query on a linked table in a Microsoft Jet-connected
ODBC
data source, you must first set the Connect property of the linked
table's
database to a valid ODBC connection string. If you only need to make a
single
pass through a Recordset opened from a Microsoft Jet-connected ODBC
data
source, you can improve performance by using dbOpenForwardOnly for the
type
argument.

If object refers to a dynaset- or snapshot-type Recordset, the new
Recordset
is of the same type object. If object
 refers to a table-type Recordset object, the type of the new object
is a
dynaset-type Recordset. You can't open new Recordset objects from
forward-only
杢ype or ODBCDirect Recordset objects.
In an ODBCDirect workspace, you can open a Recordset containing more
than one
select query in the source argument, such as

"SELECT LastName, FirstName FROM Authors
WHERE LastName = 'Smith';
SELECT Title, ISBN FROM Titles
WHERE ISBN Like '1-55615-*'"

The returned Recordset will open with the results of the first query.
To
obtain the result sets of records from subsequent queries, use the
NextRecordset method.

Note   You can send DAO queries to a variety of different database
servers
with ODBCDirect, and different servers will recognize slightly
different
dialects of SQL. Therefore, context-sensitive Help is no longer provided
 for
Microsoft Jet SQL, although online Help for Microsoft Jet SQL is still
included through the Help menu. Be sure to check the appropriate
reference
documentation for the SQL dialect of your database server when using
either
ODBCDirect connections or pass-through queries in Microsoft
Jet-connected
client/server applications.

Use the dbSeeChanges constant in a Microsoft Jet workspace if you want
to
trap changes while two or more users are editing or deleting the same
record.
For example, if two users start editing the same record, the first
user to
execute the Update method succeeds. When the second user invokes the
Update
method, a run-time error occurs. Similarly, if the second user tries
to use
the Delete method to delete the record, and the first user has already
changed it, a run-time error occurs.

Typically, if the user gets this error while updating a record, your
code
should refresh the contents of the fields and retrieve the newly
modified
values. If the error occurs while deleting a record, your code could
display
the new record data to the user and a message indicating that the data
has
recently changed. At this point, your code can request a confirmation
that
the user still wants to delete the record.

You should also use the dbSeeChanges constant if you open a Recordset in
 a
Microsoft Jet-connected ODBC workspace against a Microsoft SQL Server
6.0 (or
later) table that has an IDENTITY column, otherwise an error may
result.

In an ODBCDirect workspace, you can execute asynchronous queries by
setting
the dbRunAsync constant in the options argument. This allows your
application
to continue processing other statements while the query runs in the
background. But, you cannot access the Recordset data until the query
has
completed. To determine whether the query has finished executing,
check the
StillExecuting property of the new Recordset. If the query takes
longer to
complete than you anticipated, you can terminate execution of the
query with
the Cancel method.

Opening more than one Recordset on an ODBC data source may fail
because the
connection is busy with a prior
OpenRecordset call. One way around this is to use a server-side cursor
and
ODBCDirect, if the server supports this. Another solution is to fully
populate the Recordset by using the MoveLast method as soon as the
Recordset
is opened.

If you open a Connection object with DefaultCursorDriver set to
dbUseClientBatchCursor, you can open a Recordset to cache changes to the
 data
(known as batch updating) in an ODBCDirect workspace. Include
dbOptimisticBatc
h in the lockedits argument to enable update caching. See the Update
method
topic for details about how to write changes to disk immediately, or
to cache
changes and write them to disk as a batch.

Closing a Recordset with the Close method automatically deletes it
from the
Recordsets collection.

Note   If source refers to an SQL statement composed of a string
concatenated
with a non-integer value, and the system parameters specify a non-U.S.
decimal character such as a comma (for example, strSQL = "PRICE > " &
lngPrice, and lngPrice = 125,50), an error occurs when you try to open
the
Recordset. This is because during concatenation, the number will be
converted
to a string using your system's default decimal character, and SQL
only
accepts U.S. decimal characters.

--
为何在这里,无聊像半醉
曾在这空间,跟你相倾诉

※ 来源:.逸仙时空 Yat-sen Channel bbs.zsu.edu.cn.[FROM: 192.168.2.177]
--
※ 转寄:.逸仙时空 Yat-sen Channel bbs.zsu.edu.cn.[FROM: 210.39.3.50]
--
※ 转载:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.1.118]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店