home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / adcauto.asp < prev    next >
Text File  |  1997-08-14  |  5KB  |  172 lines

  1. <HTML>
  2. <HEAD>
  3. <TITLE> Automatically Getting Data through the DataControl </TITLE>
  4. </HEAD>
  5.  
  6. <BODY BACKGROUND="/MSADC/Samples/Addressbook/Arcadia.gif">
  7.  
  8. <CENTER><H1> Automatically Getting Data through <BR> the Data Control </H1></CENTER>
  9.  
  10. <!--
  11.     Purpose:     To demonstrate the default query scenario calling the ADC to populate a bound control.
  12.     Written By:  Microsoft Data Access Group, Microsoft Corporation
  13.     Date:        April, 1997
  14. -->
  15.  
  16. <CENTER>
  17. <Table Border=1><TR><TD ALIGN=CENTER ><FONT SIZE=2 Color="#008080">
  18. <B>Bound Data Grid</B></TD><TR
  19. ><TD>
  20.  
  21. <!--  Sheridan DataBound Grid Control, ID=GRID -->
  22.  
  23. <OBJECT CLASSID="CLSID:AC05DC80-7DF1-11d0-839E-00A024A94B3A"
  24.     CODEBASE="http://<%=Request.ServerVariables("SERVER_NAME")%>/MSADC/Samples/ssdatb32.cab"
  25.     ID="GRID"
  26.     datasrc="#ADC"
  27.     WIDTH=600 HEIGHT=150>
  28.         <PARAM NAME="AllowAddNew"   VALUE="TRUE">
  29.     <PARAM NAME="AllowDelete"   VALUE="TRUE">
  30.     <PARAM NAME="AllowUpdate"   VALUE="TRUE">    
  31.     <PARAM NAME="_Version"        VALUE="131072">
  32.     <PARAM NAME="BackColor"     VALUE="-2147483643">
  33.     <PARAM NAME="BackColorOdd"  VALUE="-2147483643">
  34.     <PARAM NAME="ForeColorEven" VALUE="0">
  35. </OBJECT>
  36. </Table>
  37.  
  38. <!-- Input Information Area -->
  39. <table>
  40. <tr><td>Server:<td><INPUT NAME="Server" SIZE=70>
  41. <tr><td>Connection:<td><INPUT NAME="Connect" SIZE=70>
  42. <tr><td>Query:<td><INPUT NAME="Query" SIZE=70>
  43. </table>
  44.  
  45. <!-- Buttons to select data source and populate visible data controls -->
  46.  
  47. <INPUT TYPE=BUTTON NAME="Run" VALUE="Run">
  48. <INPUT TYPE=BUTTON NAME="AccessQuery" VALUE="Fill Access Query Info">
  49. <INPUT TYPE=BUTTON NAME="SQLQuery" VALUE="Fill SQL Server Query Info">
  50. <HR>
  51. <INPUT TYPE=BUTTON NAME="MoveFirst" VALUE="First">
  52. <INPUT TYPE=BUTTON NAME="MovePrev" VALUE="Previous">
  53. <INPUT TYPE=BUTTON NAME="MoveNext" VALUE="Next">
  54. <INPUT TYPE=BUTTON NAME="MoveLast" VALUE="Last">
  55. <INPUT TYPE=BUTTON NAME="Submit" VALUE="Submit Changes">
  56. <INPUT TYPE=BUTTON NAME="Cancel" VALUE="Cancel Changes">
  57. </CENTER>
  58.  
  59. <!- RDS.Data Control ID ADC->
  60. <OBJECT classid="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
  61.     ID=ADC 
  62.     HEIGHT=1 WIDTH=1>
  63. </OBJECT>
  64.  
  65. <SCRIPT LANGUAGE="VBScript">
  66. Option Explicit
  67. '---- enum Values ----
  68. Const adcExecSync = 1
  69. Const adcExecAsync = 2
  70.  
  71. '---- enum Values ----
  72. Const adcFetchUpFront = 1
  73. Const adcFetchBackground = 2
  74. Const adcFetchAsync = 3
  75.  
  76. 'Populate Data Source and Query text boxes with initial data.
  77. SUB Window_OnLoad
  78.     'Change the asynchronous options such that execution is synchronous
  79.     'and Fetching can occur in the background
  80.     ADC.ExecuteOptions = adcExecSync
  81.     ADC.FetchOptions = adcFetchBackground
  82.  
  83.     Server.Value = "http://<%=Request.ServerVariables("SERVER_NAME")%>"
  84.        Connect.Value = "DSN=AdvWorks"
  85.        Query.Value = "Select * from Products"
  86. End Sub
  87.  
  88. 'Populate Query box with Microsoft Access Query.
  89. SUB AccessQuery_OnClick
  90.        Connect.Value = "DSN=AdvWorks"
  91.        Query.Value = "Select * from Products"
  92. End Sub
  93.  
  94. 'Populate Query box with SQL Server Query.
  95. SUB SQLQuery_OnClick
  96.        Connect.Value = "DSN=pubs;uid=sa;pwd=;"
  97.        Query.Value = "Select * from Authors"
  98. End Sub
  99.  
  100. SUB Run_OnClick
  101.     'Set the connection properties on the ADC object
  102.  
  103.     ADC.Server = Server.Value
  104.         ADC.Connect = Connect.Value
  105.         ADC.SQL = Query.Value
  106.  
  107.     'Get the data specified
  108.         ADC.Refresh        
  109.  
  110.       'Optional command specific to the Sheridan Grid to ensure display of the correct data
  111.     Grid.Rebind
  112.  
  113. End Sub
  114.  
  115. 'Change active Record
  116. SUB MoveFirst_OnClick
  117.     ADC.Recordset.MoveFirst
  118. END SUB
  119.  
  120. SUB MoveNext_OnClick
  121. On Error Resume Next
  122.     ADC.Recordset.MoveNext
  123.     IF ERR.Number <> 0 THEN
  124.         ADC.Recordset.MoveLast  'If already at end of recordset stay at end.
  125.     END IF
  126. END SUB
  127.  
  128. SUB MovePrev_OnClick
  129.     On Error Resume Next
  130.     ADC.Recordset.MovePrevious
  131.     IF ERR.Number <> 0 THEN
  132.         ADC.Recordset.MoveFirst  'If already at start of recordset stay at top.
  133.     END IF
  134. END SUB
  135.  
  136. SUB MoveLast_OnClick
  137.     ADC.Recordset.MoveLast
  138. END SUB
  139.  
  140.  
  141. SUB Submit_OnClick
  142.     'Send changes to data source
  143.     ADC.SubmitChanges
  144.  
  145.     'Pull fresh data
  146.     ADC.Refresh
  147.     
  148.     'Optional command specific to the Sheridan Grid to ensure display of the correct data
  149.     Grid.Rebind
  150.  
  151. End Sub
  152.  
  153. SUB Cancel_OnClick
  154.     'Cancel the changes made to the data and resore
  155.     ADC.CancelUpdate
  156.     'Pull fresh data
  157.     ADC.Refresh
  158.  
  159.     'Optional command specific to the Sheridan Grid to ensure display of the correct data
  160.     Grid.Rebind
  161. End Sub
  162.  
  163. </SCRIPT>
  164.  
  165. <!-- Link to View Source -->
  166.  
  167. <TABLE BORDER=3><TR><TD><!--#include file="srcform.inc"--></TABLE>
  168. <Center>This site powered by the Microsoft Data Access Components.</Center>
  169.  
  170. </BODY>
  171. </HTML>
  172.