ast month, we saw how we could use the Tabular Data Control (TDC) to display recordset data in a paged fashion in Internet Explorer. The TDC is useful when you want to display static lists that are stored as text files on your Web server?for example, price lists, contact lists, phone directories, etc.
This month, we are going to be looking at Microsoft’s Remote Data Services. As you will see, a number of steps that we used last month are identical using this technique. I have repeated some of the steps so that you don’t have to look up last month’s Solution each time.
Microsoft’s Remote Data Services (RDS) is a component that ships with the Microsoft Data Access Components (MDAC), version 2.0. RDS provides a nearly identical functionality to the TDC but with one major difference. RDS can be used to access live data from a database and send a recordset object back to the browser where it can then be manipulated. Thus, you can send a recordset object to the browser and enable a paging mechanism where the user navigates from page to page without making a round trip back to the server for the data.
In order to use RDS, remember:
- To use RDS, you need to install RDS as a component on your Web server. This is normally installed on IIS as part of the Windows NT option pack. This process installs two special components on the Web Server?the RDS DataFactory object and the RDS DataSpace object. Both of these are COM components that are invoked by the RDS data control that you will be using in your HTML page.
- On your Web site, a virtual directory called MSADC must exist on the root of each Web site. This virtual directory must point to the Program FilesCommon FilesSystemMSADC folder. The permissions of this folder must be set to Execute (Including Script) (Internet Information Server [IIS] 4.0) or Scripts and Executables (IIS 5.0). The MSADC virtual directory must exist as a subdirectory of any Web site that uses RDS.
- On your Web server, make sure you have an ODBC System DSN created with a specific user name and password to access your database. Make this user’s permissions as restrictive as possible?that is, if all you are interested in is for this user to read data from a specific table within the database, then make sure that this is all the permissions the user has. If you are using Access as your database, make sure you create a new user with very little access permissions, and not use the default Admin user. If you are using SQL Server or Oracle, create a new user login with very restrictive permissions. We will see later why we need to make sure the user has very restrictive permissions. This solution does not provide details on how to set up users and access permissions on your database. Consult the documentation on your database or contact your database administrator for help in this area.
I am going to assume that you have the above set up on your Web server. For my demonstration, I am going to use the NorthWind database that ships with SQL Server 7, which is a duplicate of the Access NorthWind database. I have created a new user login in my server called ‘asppro’ and have given access permissions to only one table ‘Customers’ within the Northwind database. This is because we are only going to do a read of data from that table for this solution.
Using the Remote Data Control on Your Page
If you use an ActiveX control in your Web pages, you need to provide information about the control as well as information about where the control can be found for downloading. The user is usually prompted with a dialog box before the ActiveX control is downloaded. The control then needs to be installed before the Web page can use it. All this makes the use of ActiveX controls on Web pages less appealing. However, what if you could use ActiveX controls that are built into the browser itself? Then there is nothing to download, and your Web page simply starts using the control.
When you install Internet Explorer on your machine, it silently installs a number of different ActiveX controls. These are lightweight controls that are similar to the common controls that ships with Windows?the treeview control, the listview control, etc?that are used by Windows Explorer.
One of the ActiveX controls that is automatically installed on your machine by IE is the Remote Data Control (RDC). The RDC acts as an invisible container that holds a set of records on your Web page that you can manipulate within your code. If you have programmed with Visual Basic, the RDC is very similar to the Visual Basic Data Control, except it is not visible. Like the Visual Basic Data Control, you can manipulate it using your code?you can move from record to record and access its data.
Consider the following scenario: suppose you had a list of data you wanted to display on your Web page; for example, a list of customer information. You could display the list as rows and columns using the HTML
|pair. If you had a hundred rows in the list, you would need to code a hundred row tags for your HTML table. The RDC allows you to do it with a single row tag. In addition, it enables you to provide navigation capabilities.
|for each column. Within thesection, we code a single row using a single
|tag pair. Within the cell, the TD, we use the HTML container tag