To bind a data access page to a disconnected recordset

Source: Internet
Author: User
Tags bind connect
Disconnect | access | recordsets | data Meyyammai Subramanian
Microsoft Corporation

April 2001

Apply to:
Microsoft®access 2002

Summary: This article describes how to bind a data access page to a disconnected ADO recordset.

Directory
Brief introduction
To create a data access page that uses a disconnected set of records

Brief introduction
The disconnected recordset is an object in the client cache that does not connect to the server in real time. With disconnected recordsets, the ActiveX® data Object (ADO) allows you to create recordsets, disconnect from the data source, and enable users to view and edit the recordset offline.

For example, the category data access page asks whether the page should use disconnected data. If the user clicks Yes, the page prompts the user to enter the path of the disconnected recordset. If the user clicks No, the page uses live data.

To create a data access page that uses a disconnected set of records
Create a data access page in Design view.


Add the controls and grouping levels that you want. For example, create a Categories page that combines product records under different categories.


Add code to the BeforeInitialBind event to connect to a disconnected recordset, or to connect to real-time data.
The following is an example of the BeforeInitialBind event procedure.

<script language=vbscript Event=beforeinitialbind (info) for=msodsc>
<!--
Dim RS
Dim strShapeText
Dim strConnectionString
Dim strDataSource
Adopenkeyset=1
Adlockoptimistic=3

If Vbyes=msgbox ("Use disconnected recordset?"). ", vbYesNo) Then
On Error Resume Next
strDataSource = InputBox ("Please enter the _ to use
The path of the disconnected recordset. "," Enter Path ", _
"C:\Program Files\Microsoft Office\office10\samples\ _
Northwind.mdb ")
strShapeText = MSODSC. Rootrecordsetdefs (0). Shapetext
strConnectionString = "PROVIDER=MSDATASHAPE.1; _
Persist security Info=false;data source= "& strDataSource _
& "; User id=admin;data provider=microsoft.jet.oledb.4.0 "

Set rs = CreateObject ("ADODB.") Recordset ")
Rs. Open strShapeText, strConnectionString, adOpenKeyset, _
adLockOptimistic

If Err. Number <> 0 Then
MsgBox "Error:" & Err.Description & "Error" & Err.Number
End If

MSODSC. Setrootrecordset "Categories", RS
End If
-->
</SCRIPT>

Attention:

You cannot use a data access page that is bound to a disconnected recordset correctly from within Microsoft Access. You should open the page in Microsoft Internet Explorer to view it properly.


When you create a Visual basic®scripting Edition (VBScript) block of a Microsoft®office data source control (MSODSC) event, you must add the parameter to the event name, as follows:
<script language=vbscript FOR=MSODSC event=current (oventinfo) >

The oEventInfo parameter is used to return specific information about the event to the script. This parameter must be added regardless of whether this parameter is used or the script will not run.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.