wayne plourde

software architect mcad mcsd scjp

home | articles | book | resume | projects | contact

14 - Remote Data Services (Outline and Notes)

ASP 3.0 The Complete Reference

Chapter 14

Remote Data Services (Outline and Notes)

Disconnected Data

Why Client Side Data?

Advantages refresh Data only

Disadvantages Synchronizing not much worse that standard HTML

Browser Limitations

Round Trip capabilities

Design considerations

Moving Data to a frame separate from display

allows you to change between grid and detail views

DSO - Data Source Objects

client side container for data allows binding

Techniques for Client side data

Synchronizing back on the server

Remote Data Objects

Good option for relational database servers

passing disconnected recordsets

Can provide direct access to data

Middle Tier can be constructed to further access

DSO

Using Remote Scripting with Javascript Arrays

building a javascript array

Works in Netscape

No DSO

Tabular Data Control

Good option for non database data

IE Only

No Easy Round Trip

DSO

Java Applet

JDBC

Corba

Java is also the facilitator for Remote Scripting

Third Party ActiveX Controls

Sheridan Tools

IE Only

Some DSO

XML Data Islands

Using ADO perisistence XML or ATDG

Round trip

DSO

Chapter 14 for in depth discussion of

Building Grid and Detail Pages with Remote Data Services

This chapter will explain Remote Data Services (RDS) and how to best use RDS with ASP to access Client Side and Server Side Data

How does it Differ from ADO?

Client can build and Submit Query string

However, this exposes the database

Important to ensure that database objects are secure

RDS Object Model

Diagram

RDS.DataSpace

Your client application must specify the server and the server program to invoke. In return, your application receives a reference to the server program and can treat the reference as if it were the server program itself.

The RDS object model embodies this functionality with the RDS.DataSpace object.

The server program is specified with a program identifier, or ProgID. The server uses the ProgID and the server machine's registry to locate information about the actual program to initiate.

RDS makes a distinction internally depending on whether the server program is on a remote server across the Internet or an intranet; a server on a local area network; or not on a server at all, but instead on a local dynamic-link library (DLL). This distinction determines how information is exchanged between the client and the server, and makes a tangible difference in the type of reference returned to your client application. However, from your point of view, this distinction has no special meaning. All that matters is that you receive a usable program reference.

RDSServer.DataFactory

RDS provides a default server program that can either perform an SQL query against the data source and return a Recordset object, or take a Recordset object and update the data source.

The RDS object model embodies this functionality with the RDSServer.DataFactory object.

In addition, this object has a method for creating an empty Recordset object that you can fill programmatically (CreateRecordset), and another method for converting a Recordset object into a text string to build a Web page (ConvertToString).

With ADO, you can override some of the standard connection and command behavior of the RDSServer.DataFactory with a DataFactory handler and a customization file that contains connection, command, and security parameters.

The server program is sometimes called a business object. You can write your own custom business object that can perform complicated data access, validity checks, and so on. Even when writing a custom business object, you can create an instance of an RDSServer.DataFactory object and use some of its methods to accomplish your own tasks.

RDS.DataControl

RDS provides a means to combine the functionality of the RDS.DataSpace and RDSServer.DataFactory, and also enable visual controls to easily use the Recordset object returned by a query from a data source. RDS attempts, for the most common case, to do as much as possible to automatically gain access to information on a server and display it in a visual control.

The RDS object model embodies this functionality with the RDS.DataControl object.

The RDS.DataControl has two aspects. One aspect pertains to the data source. If you set the command and connection properties of the RDS.DataControl, it will automatically use the RDS.DataSpace to create a reference to the default RDSServer.DataFactory object. Then the RDSServer.DataFactory will use the connection property value to connect to the data source, use the command property value to obtain a Recordset from the data source, and then return the Recordset object to the RDS.DataControl.

The second aspect pertains to the display of returned Recordset information in a visual control. You can associate a visual control with the RDS.DataControl (in a process called binding) and gain access to the information in the associated Recordset object, displaying query results on a Web page in Internet Explorer. Each RDS.DataControl object binds one Recordset object, representing the results of a single query, to one or more visual controls (for example, a text box, combo box, grid control, and so forth). There may be more than one RDS.DataControl object on each page. Each RDS.DataControl object can be connected to a different data source and contain the results of a separate query.

The RDS.DataControl object also has its own methods for navigating, sorting, and filtering the rows of the associated Recordset object. These methods are similar, but not the same as the methods on the ADO Recordset object.

What you need

Installing RDS

Referencing Type Libraries

VBScript

1

2

3

4

5

6

7

8

9

10

The Example

Figure 1: Screen Shot of Grid with RDS

VBScript

1

2

3

4

5

6

7

8

9

10

VBScript

1

2

3

4

5

6

7

8

9

10

VBScript

1

2

3

4

5

6

7

8

9

10

Retrieving Data

data source in outer document

proxy concept similar to Remote Scripting

RDS.DataControl

The Default Server

VBScript

1

2

3

4

Connecting to Data

VBScript

1

2

3

4

5

6

7

8

9

10

Picking up the Recordset

VBScript

1

2

3

4

5

6

7

8

9

10

Synchronous / Asynchronous execution

The RDS.DataControl object runs in asynchronous mode by default. If you require synchronous execution for your application, set the ExecuteOptions parameter equal to adcExecSync and the FetchOptions parameter equal to adcFetchUpFront, as shown in the following example.

VBScript

1

2

3

4

5

6

7

8

9

10

Fetching Options

UpFront

Background

Asynch

allows canceling of the request

VBScript

1

2

3

4

5

6

7

8

9

10

Data Events

VBScript

1

2

3

4

5

6

7

8

9

10

Checking for Errors

VBScript

1

2

3

4

5

6

7

8

9

10

Data Factory Customization

However, the RDSServer.DataFactory is limited to performing queries and updates. It cannot perform any validation or processing on the connection or command strings.

With ADO, you can specify that the DataFactory work in conjunction with another type of server program called a handler. The handler can modify client connection and command strings before they are used to access the data source. In addition, the handler can enforce access rights, which govern the ability of the client to read and write data to the data source.

msdfmap.ini Initializes the DataFactory handler core

Validation

VBScript

1

2

3

4

5

6

7

8

9

10

Multiple Data Sources

VBScript

1

2

3

4

5

6

7

8

9

10

Data Binding

Similar to previous examples

RDS.DataControl

VBScript

1

2

3

4

5

6

7

8

9

10

Paging Data

VBScript

1

2

3

4

5

6

7

8

9

10

Sorting Filtering through local indexes

see previous chapter for specifics

Inserting data

VBScript

1

2

3

4

5

6

7

8

9

10

Updating data

VBScript

1

2

3

4

5

6

7

8

9

10

Deleting data

VBScript

1

2

3

4

5

6

7

8

9

10

Sending Data back to the Server

Review resync issues for disconnected recordsets

Client side

VBScript

1

2

3

4

5

6

7

8

9

10

Server Side - Resynch

VBScript

1

2

3

4

5

6

7

8

9

10

Server Side Update

VBScript

1

2

3

4

5

6

7

8

9

10

Handling Errors

Building Grid and Detail Pages with Remote Scripting

Just cover transfer and display

Overview

What you need

see remote scripting chapter for server setup

only

The Example

Figure 2: Screen Shot

VBScript

1

2

3

4

5

6

7

8

9

10

VBScript

1

2

3

4

5

6

7

8

9

10

VBScript

1

2

3

4

5

6

7

8

9

10

Retrieving Data

translating Database data into Javascript arrays

refreshing data

passing parameters

VBScript

1

2

3

4

5

6

7

8

9

10

Writing Data to a page

Similar to building page on server side

Paging

VBScript

1

2

3

4

5

6

7

8

9

10

Total Count

VBScript

1

2

3

4

5

6

7

8

9

10

Returning Data to the Server

Parsing the Array

VBScript

1

2

3

4

5

6

7

8

9

10