Data Access and Transactions |
The example uses the Sheridan data-bound grid control, which is available from the Sheridan Web site, http://www.shersoft.com, or as part of the MDAC samples. If you have installed the MDAC samples, the .cab file for the grid control can be found at http://<yourserver>msadc/Samples/ssdatb32.cab.
<%@ LANGUAGE=VBScript EnableSessionState=False %>
<!-- #include file="adcvbs.inc" -->
<HTML>
<HEAD>
<TITLE>A databound grid control</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF TEXT="#000000">
<!-- RDS.DataControl -->
<OBJECT ID="DATA" WIDTH=1 HEIGHT=1
CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33">
</OBJECT>
<!-- Sheridan data-bound grid control (note DATASRC) -->
<OBJECT ID="GRID" WIDTH=600 HEIGHT=200 DATASRC="#DATA"
CLASSID="clsid:00028C00-0000-0000-0000-000000000046">
</OBJECT>
--><SCRIPT Language=VBScript>
Sub Window_OnLoad
If DATA.ReadyState <> <%=adcReadyStateComplete%> Then
MsgBox "Query results still arriving, Please wait"
Else
DATA.Server = "http://<%Request.ServerVariables("SERVER_NAME")%>"
DATA.Connect = "DSN=AdvWorks"
DATA.SQL = "Select * from Products"
DATA.Refresh
GRID.Rebind
End if
END SUB
</SCRIPT>
</BODY>
</HTML>
Each RDS.DataControl object can be connected to a different data source and contain the results of a separate query. When you use the RDS.DataControl object to send a query to a database, the RDS server-side components return an ADODB.Recordset object to the client. On the client, the RDS proxy creates a client-side cursor and an ADOR.Recordset object to manipulate the returned records. You don’t necessarily have to write any ADOspecific code to make this happen—RDS handles this for you when you use the RDS.DataControl object.
The figure below shows how the client-side and server-side components of a Web-based ADO application work together to process a user’s query and display information from a database.