home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / iis4_05.cab / iiatmd2.asp < prev    next >
Encoding:
Text File  |  1997-08-27  |  26.5 KB  |  402 lines

  1. <%@ Language=VBScript EnableSessionState=False %>
  2. <%
  3.   Response.Expires = 0 
  4.   LessonFile = Request.ServerVariables("SCRIPT_NAME")
  5.  
  6.   ScriptLanguagePreference = Request.Cookies("ScriptLanguagePreference")
  7.  
  8.   If ScriptLanguagePreference = "" Then
  9.     ScriptLanguagePreference = Request.QueryString("ScriptLanguagePreference")
  10.     If ScriptLanguagePreference = "" Then
  11.       Response.Redirect "/IISHELP/IIS/HTM/ASP/IISelect.asp?LessonFile=" & Ucase(Server.URLEncode(LessonFile))
  12.     End If
  13.   End If
  14.  
  15.  
  16. 'Determine the physical path for the current page and then remove the
  17. 'name of the file from the path (leaving just the directory).
  18. MainPath = Request.ServerVariables("PATH_TRANSLATED")
  19. Length = Len(MainPath)
  20. i = 0
  21. Do Until (i  = 2)
  22.   Do While (Mid(MainPath, Length, 1) <> "\")
  23.     Length = Length - 1      
  24.   Loop  
  25. i = i + 1
  26. MainPath = left(MainPath, (Length-1)) 
  27. Loop
  28. FilePath = left(MainPath, Length) + "\tutorial"
  29.  
  30.  
  31. 'Determine the virtual path for the current page and then remove the
  32. 'name of the file from the path (leaving just the directory).
  33. MainPath = Request.ServerVariables("PATH_INFO")
  34.  
  35. Length = Len(MainPath)
  36. i = 0
  37. Do Until (i  = 2)
  38.   Do While (Mid(MainPath, Length, 1) <> "/")
  39.     Length = Length - 1      
  40.   Loop  
  41. i = i + 1
  42. MainPath = left(MainPath, (Length-1)) 
  43. Loop
  44. VirtFilePath = left(MainPath, Length) + "/Tutorial"
  45.  
  46.  
  47. %>
  48. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  49. <html><head><title>Module 2: Using  ActiveX Components</title>
  50.  
  51. <SCRIPT LANGUAGE="JavaScript">
  52.     TempString = navigator.appVersion
  53.     if (navigator.appName == "Microsoft Internet Explorer"){    
  54. // Check to see if browser is Microsoft
  55.         if (TempString.indexOf ("4.") >= 0){
  56. // Check to see if it is IE 4
  57.             document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
  58.         }
  59.         else {
  60.             document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
  61.         }
  62.     }
  63.     else if (navigator.appName == "Netscape") {                        
  64. // Check to see if browser is Netscape
  65.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
  66.     }
  67.     else
  68.         document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
  69. </script> 
  70.  
  71.  
  72.  
  73. <META NAME="DESCRIPTION" CONTENT="This is an Active Server Pages (ASP) tutorial where you can lean how to use ActiveX server components to extend your scripting capabilities. In this module, you will use ActiveX components that are included with ASP to activate a sample Web site and query a database."></head>
  74.  
  75. <body bgcolor="#FFFFFF" text="#000000"><font face="Verdana,Arial,Helvetica">
  76.  
  77.  
  78. <h1><a name="module1">Module 2: Using ActiveX Components</a></h1>
  79.  
  80. <p><a href="iiselect.asp?LessonFile=<%= Ucase(Server.URLEncode(LessonFile) )%>"><strong>Choose a scripting language for this lesson.</strong></a> </p>
  81.  
  82.  
  83. <p>ActiveX server <em>components</em> extend your scripting capabilities by providing a compact, reusable, and secure means of gaining access to information. For example, ASP's Database Access component enables scripts to query databases. Thus, whenever you want to query a database from a script, you can use the Database Access component; you need not write complex scripts to perform this task. You can call components from any script or programming language that supports Automation (ActiveX server components are Automation servers). In this module, you will use ActiveX components that are included with ASP to activate a sample Web site.</p>
  84.  
  85. <p>By now, you should be familiar with the basics of writing .asp files. If not, complete <a href="iiatmd1.asp">Module 1</a> of this tutorial.</p>
  86.  
  87. <p><strong><a name="note">Important</a></strong>   </p>
  88.  
  89. <ul>
  90. <li>To save and view your work in this module, you must enable Write and Script Web server permissions for the <%= VirtFilePath %> virtual directory on the <%= Request.ServerVariables("SERVER_NAME")%> Web server (with Active Server Pages installed).  For more information, see <a href="/iishelp/iis/htm/core/iiwspsc.htm">Setting Web Server Permissions</a>. </li>
  91.  
  92. </ul>
  93.  
  94.  <hr>
  95.  
  96. <h2><a name="H2_37665281"></a>Lesson 1: Using the Ad Rotator Component</h2>
  97.  
  98. <p>Internet Web sites often provide advertising space. To keep sites visually interesting and to display ads from several advertisers in limited space, you might want to cycle through different advertisements. The Ad Rotator component simplifies the task of displaying each ad in turn and makes it easier to add new ads.  Additionally, you can easily add or changes an ad hyperlinks, that enable users to click an ad and visit the advertiser's Web site.  In this lesson, you will create a script for that calls the Ad Rotator component to rotate through four randomly selected ads. Click the Show Me button below to see an example of an ad you are going to display, then click the button repeatedly to rotate through other <a name="usingtheadrotatorcomponent">ads</a>.<hr>
  99. <!--#include virtual="/iishelp/iis/htm/tutorial/script4.asp" --></p>
  100.  
  101. <hr>
  102.  
  103. <h3><a name="createtheadfile">Create the Ad File</a></h3>
  104.  
  105. <p>We have created a Web page for a fictitious business, called Bayshore Travel, where you will insert the ad rotator script.  You can also create a simple text file to tell the Ad Rotator component which ads to insert and for what percentage of time each ad should be displayed. We have already created a file containing ads for you. To view it, use your text editor to open the file Adrot.txt in the <%= Request.ServerVariables("SERVER_NAME")%> Web server's Tutorial directory (<%= FilePath %>). </p>
  106.  
  107. <p>The first line of the file sets the script that will be called when a user clicks on an advertisement; in this case, Redirect.asp. You can modify the Redirect.asp file to perform a specific action, such as tracking ad popularity, prior to linking the user to the advertiser's Web site. The following three lines establish the width, height, and border of the ad images.</p>
  108.  
  109. <pre><font size="3" face="courier">redirect /iishelp/iis/htm/tutorial/redirect.asp
  110. width 180
  111. height 180
  112. border 1</font></pre>
  113.  
  114.  
  115. <p>Next, the file contains ad data. For each ad, this includes the image to use, the URL to go to when a user clicks the ad (in this case, after going to Redirect.asp), the text associated with the image, and the percentage of time this ad is to be displayed:</p>
  116.  
  117. <pre><font size="3" face="courier">/iishelp/iis/htm/tutorial/nyc.jpg
  118. http://www.microsoft.com
  119. Big Deals in the Big Apple
  120. 35</font></pre>
  121.  
  122.  
  123. <p>By maintaining the ad information in a separate file, a different group at your organization can update the Adrot.txt file without requiring you to update your ASP page. Different groups can maintain different files of ads for different parts of your site. </p>
  124.  
  125. <h3><a name="createthescript">Create the Script</a></h3>
  126.  
  127. <ol>
  128. <li>Use your text editor to open the file Bayshore.asp in the <%= Request.ServerVariables("SERVER_NAME")%> Web server's Tutorial directory (<%= FilePath %>). 
  129. <br><br></li>
  130.   <li>Search for the words "<em>Define Scripting Language</em>", underneath this text line copy and paste the following lines of script: </li>
  131.  
  132. <pre><font size="3" face="courier"><%@ LANGUAGE = "<%=ScriptLanguagePreference%>" %></font></pre>
  133. <p>Always add this tag as the first script line in you .asp file so that the Web server knows what language your using to write your script.<!--</p>--><br>
  134.  
  135. <li>Search for the words “<em>Tutorial Lesson: Ad Rotator</em>.” You will add your script here.<br><br></li>
  136.  
  137. <li>Create an instance of the Ad Rotator component and assign it to the variable <font face="courier" size="3"><code>Ad</code></font> by copying the following script command and pasting it into your text editor (after the text line from the previous step): </li>
  138.  
  139. <pre><font size="3" face="courier"><% <%
  140.   If ScriptLanguagePreference = "JScript" Then
  141.  
  142. %><%Else%>Set<% End If %> Ad = Server.CreateObject("MSWC.Adrotator") %> </font></pre>
  143. <p>Assigning a component instance to a variable enables you to refer to a component later in a script.<!--</p>--><br>
  144.  
  145. <p>If another user has previously completed this portion of the tutorial, this script command will already be in place. Paste the copied script over the existing script, or copy an unedited copy of Bayshore.asp from the Template (<%=FilePath%>\template) directory to the Tutorial directory.<!--</p>--><br>
  146.  
  147.  
  148. <li>To display a new ad, you use the <strong>GetAdvertisement</strong> method of the Ad Rotator component. Add the following command to your script: </li>
  149. <pre><font size="3" face="courier"><%<%
  150.   If ScriptLanguagePreference = "JScript" Then
  151. %>Response.Write(Ad.GetAdvertisement("adrot.txt"))<%Else%>= Ad.GetAdvertisement("adrot.txt")<% End If %>%> </font></pre>
  152.  
  153. <p>The <strong>GetAdvertisement</strong> method takes one parameter (the name of the file containing the ad information, in this case Adrot.txt). On the basis of this parameter, the method returns a fully formatted HTML <IMG> tag with the appropriate ad. The variable name you assigned to the Ad Rotator component instance, <strong>Ad</strong>, precedes the method, <strong>GetAdvertisement</strong>, and the path for the file Adrot.txt. The equal sign sends the value returned by the method (the actual ad) to the client browser.<!--</p>--><br>
  154.  
  155.  
  156. <li>Save changes to Bayshore.asp in text format and exit your text editor. Be sure your text editor does not replace the .asp file name extension.
  157. <br><br></li>
  158.  
  159. <li>To verify that the ASP page you’ve created works (after which you can return to this tutorial by clicking Back in your browser), point your browser to
  160. <a href="http://<%= Request.ServerVariables("SERVER_NAME")%>/iishelp/iis/htm/tutorial/bayshore.asp">http://<%= Request.ServerVariables("SERVER_NAME")%>/IISHelp/IIS/Help/Htm/Tutorial/Bayshore.asp</a> </li>
  161.  
  162. </ol>
  163. <hr>
  164.  
  165. <h2><a name="usingthebrowsercapabilitiescomponent">Lesson 2: Using the Browser Capabilities component</a></h2>
  166.  
  167. <p>Not all browsers support the incredibly broad range of today's Internet technologies. ActiveX controls, Java™ applets, streaming video, and Dynamic HTML are just some examples of features that some browsers support and others do not. Using ASP's Browser Capabilities component, you can design "intelligent" Web pages that present content in formats appropriate for the capabilities of the browser rendering your page. For example, your Web page can use the Browser Capabilities component to determine whether a user's browser supports an interactive, ActiveX-driven logo displayed on your page, and if the browser does not, display the logo in an alternate form, such as static image. </p>
  168.  
  169. <p>In this lesson, you will enhance the Ad Rotator script you created in Lesson 1 to include script for activating a Java applet, which runs exclusively on the user's Web browser. If a user’s browser supports Java applets, the user sees a set of ads that appear one after another, with a variety of dynamic “slide-ins” and “slide-outs.” If the browser does not support Java applets, then the user sees alternating static ads generated by the Ad Rotator component whenever the user refreshes the Web page.</p>
  170.  
  171. <p>An example of a browser-sensitive rotating ad appears below. (If your browser does not support Java applets, you will see the same static ads that you saw in <a href="#usingtheadrotatorcomponent">Lesson 1</a>.)</p>
  172.  
  173. <hr>
  174.  
  175. <p><strong><span style="color: #0000FF"><font color="#0000FF">Important</font></span></strong>   You must complete <a href="#usingtheadrotatorcomponent">Lesson 1</a> before doing this lesson. </p>
  176.  
  177. <hr>
  178.  
  179. <!--#include virtual="/iishelp/iis/htm/tutorial/script5.asp" -->
  180.  
  181. <hr>
  182.  
  183. <h3><a name="createthescriptb">Create the Script </a></h3>
  184.  
  185. <ol>
  186. <li>Start your text editor and open the file Bayshore.asp in the Tutorial directory (<%= FilePath %>).<br><br></li>
  187.  
  188. <li>Search for the words “Tutorial Lesson: Start Browser Capabilities.”, below this text line,  you will add your script.<br><br></li>
  189.  
  190. <li>Create an instance of the Browser Capabilities component and assign it the variable <font face="courier" size="3"><code>objBrowser</code></font> by copying the following script command and pasting it into Bayshore.asp: <pre><font size="3" face="courier"><% <%
  191.   If ScriptLanguagePreference = "JScript" Then
  192. %><%Else%>Set<% End If %>objBrowser = Server.CreateObject("MSWC.BrowserType") %></font></pre>
  193.  
  194. <p>If another user has previously completed this portion of the tutorial, these lines of script will already be in place. Paste the copied lines of script over the existing script, or copy an unused version of Bayshore.asp from the Template subdirectory (<%=FilePath%>\template) to the Tutorial directory.<!--</p>--><br>
  195.  
  196. <li>
  197. <% If ScriptLanguagePreference = "JScript" Then %>
  198. Use the JScript <strong>if...else</strong>
  199. <% Else %>
  200. Use the VBScript <strong>If...Then...Else</strong>
  201. <% End If %>
  202.  statement to determine whether or not a client browser supports Java applets. If it does, the Java applet will be used; if the browser does not support Java applets, the server-side Ad Rotator component will be used. To incorporate this logic, copy the following script and paste it after the <font face="courier" size="3"><code><% <%
  203.   If ScriptLanguagePreference = "JScript" Then
  204. %><%Else%>Set<% End If %> objBrowser...%></code></font> 
  205. statement you inserted in step 2: 
  206. <pre><font size="3" face="courier"><% <%
  207.   If ScriptLanguagePreference = "JScript" Then
  208. %>if (objBrowser.javaapplets == true )  {<%Else%>If objBrowser.javaapplets = "True" Then<% End If %>
  209.  
  210. %><APPLET
  211.     CODE=CoolScrl.class
  212.     NAME=coolscrl
  213.     CODEBASE="http://<%=Request.ServerVariables("SERVER_NAME")%>/iishelp/iis/htm/tutorial/"    
  214.     WIDTH=150
  215.     HEIGHT=150>
  216.  
  217. <!--#INCLUDE FILE="adparamt.asp"-->
  218.  
  219.  
  220. <% <%
  221.   If ScriptLanguagePreference = "JScript" Then
  222. %> }
  223.   else<%Else%>Else<% End If %> %> </font></pre>
  224.  
  225.  
  226. <p>If another user has previously completed this portion of the tutorial, these lines of script will already be in place. Paste the copied script over the existing script, or copy an unused version of Bayshore.asp from the Template subdirectory (<%=FilePath%>\template) to the Tutorial directory.
  227. <!--</p>--><br>
  228.  
  229. <p>The Browser Capabilities component’s <strong>javaapplets</strong> property determines whether the browser supports ActiveX controls. The script uses the HTML <font face="courier" size="3"><code><APPLET></code></font> tag to insert a 
  230. Java applet into the Web page. The tag's attributes specify the name and location of the the applet file, and size of the ad images. In this example, the applet, CoolScrl.class, rotates ad images and creates dynamic "sliding" transitions between ads. The <strong>#INCLUDE</strong> statement inserts a file called Adparamt.asp into Bayshore.asp.  Adparamt.asp contains HTML <PARAM> tags that set specific values for the applet: the ad file names, locations, and destination URLs.  If you are interested in viewing the contents of Adparamt.asp, it is located in the <%= Request.ServerVariables("SERVER_NAME")%> Web server's Tutorial directory (<%= FilePath %>) and you can open it in a text editor, such as Notepad.<!--</p>--><br>
  231.  
  232. </li>
  233.  
  234. <li>Search for the words “<em>Tutorial Lesson - End Browser Capabilities</em>.” Below this text line, copy and paste the following script command to end the 
  235. <strong><%
  236.   If ScriptLanguagePreference = "JScript" Then
  237. %>if<%Else%>If...Then...Else<% End If %></strong> statement: 
  238.  
  239. <pre><font size="3" face="courier"><%<%
  240.   If ScriptLanguagePreference = "JScript" Then
  241. %>
  242. }
  243. <%Else%>End If <% End If %>%> </font></pre>
  244.  
  245. <p>If another user has previously completed this portion of the tutorial, this script command will already be in place. Paste the copied script over the existing script, or copy an unused version of Bayshore.asp from the Template subdirectory (<%=FilePath%>\template) to the tutorial directory.<!--</p>--><br></li>
  246.  
  247. <li>Save changes to Bayshore.asp as a text file and exit your text editor. Be sure your text editor does not replace the .asp file name extension.
  248. <br><br></li>
  249.  
  250. <li>To verify that the Active Server Page you’ve created works (after which you can return to this Tutorial by clicking Back in your browser), point your browser to <a href="http://<%= Request.ServerVariables("SERVER_NAME")%>/iishelp/iis/htm/tutorial/bayshore.asp">http://<%= Request.ServerVariables("SERVER_NAME")%>/IISHelp/IIS/Help/Htm/Tutorial/Bayshore.asp. </a></li>
  251. </ol>
  252.  
  253. <p><strong>Note</strong>    The file Browscap.ini (placed in Winnt\System32\Inetsrv by default) contains the data necessary for the Browser Capabilities component to recognize a browser and its capabilities. You will need to add new data to this file as new browsers are developed, or if you are using browser-dependent features that are not listed in the default Browscap.ini file.</p>
  254.  
  255. <hr>
  256.  
  257. <h2><a name="usingthedatabaseaccesscomponent">Lesson 3: Using the Database Access Component </a></h2>
  258.  
  259. <p>The ASP Database Access component uses ActiveX Data Objects (ADO) to provide easy access to information stored in a database (or in another tabular data structure such as a spreadsheet) that complies with the Open Database Connectivity (ODBC) standard. In this lesson, you will connect to a Microsoft® Access customer database and display a listing of its contents. You will learn how to extract data using the SQL <strong><a name="select">SELECT</a></strong> statement and create an HTML table to display the results.</p>
  260.  
  261. <hr>
  262. <!--#include virtual="/iishelp/iis/htm/tutorial/script6.asp" -->
  263. <hr>
  264.  
  265. <h3><a name="identifythedatabase">Identify the Database</a></h3>
  266.  
  267. <p>Before using a database with the Database Access component, you must identify the database in the ODBC application in Control Panel. 
  268. In this example, you will use a Microsoft® Access database that is provided with this Tutorial.</p>
  269.  
  270. <ol>
  271. <li>At the computer running your Web server (<%= Request.ServerVariables("SERVER_NAME")%>), open <strong>Control Panel</strong>. 
  272. <br><br></li>
  273.  
  274. <li>Double-click the ODBC icon, and then click <strong>System DSN</strong>.
  275.  
  276. <p>The DSN tells the database driver, a program used to configure and communicate with the database, where the database is located.  You can create three types of DSNs: <strong>User</strong>, which is available only to you; <strong>System</strong>, which is available to anyone using the 
  277. computer; and <strong>File</strong>, which saves the DSN information as a file and allows all users to access the same database drivers. The DSN for use with this tutorial must be of the <strong>System</strong> type.</p>
  278.  
  279. <li>Click <strong>Add</strong>, choose the <strong>Microsoft Access Driver</strong>, and then click <strong>Finish</strong>.
  280. <br><br></li>
  281.  
  282. <li>In the <strong>Data Source Name </strong>box, type <strong>ASPTutorial</strong>, and then click <strong>Select</strong>. Select the BTCustmr.mdb file (In the WINNT\Help\IIS\Htm\Tutorial directory by default), and click <strong>OK</strong>.
  283. <br><br></li>
  284.  
  285. <li>Click <strong>OK</strong> to close the dialog boxes. </li>
  286. </ol>
  287.  
  288. <h3><a name="createthecomponentinstance">Create the Component Instance</a></h3>
  289.  
  290. <ol>
  291.  
  292. <li>Use your text editor to open the file Database.asp in the <%= Request.ServerVariables("SERVER_NAME")%> Web server's Tutorial directory ( <%= FilePath %>).<br><br></li>
  293.  
  294. <li>Search for the words "<em>Define Scripting Language</em>", underneath this text line copy and paste the following lines of script: </li>
  295.  
  296. <pre><font size="3" face="courier"><%@ LANGUAGE = "<%=ScriptLanguagePreference%>" %></font></pre>
  297. <p>Always be sure to add this tag as the first script line in all of your .asp files.<!--</p>--><br>
  298.  
  299. <li>Search for the words “<em>Tutorial Lesson - ADO Connection</em>,” underneath this text line you will copy and paste your script.
  300. <br><br></li>
  301.  
  302. <li>As always, you need to create an instance of an object in order to use it. Copy and paste the following script command: </li>
  303. <pre><font size="3" face="courier"><% 
  304. <%
  305.   If ScriptLanguagePreference = "JScript" Then
  306. %><%Else%>Set<% End If %> objConnection = Server.CreateObject("ADODB.Connection")  </font></pre>
  307.  
  308. <p>If another user has previously completed this portion of the tutorial, this script command will already be in place underneath the "Tutorial Lesson" comment. Paste the copied script over the existing script, or copy an unused version of Database.asp from the Template subdirectory (<%=FilePath%>7template) to the Tutorial directory.<!--</p>--><br>
  309.  
  310. <li>For the Database Access component, you also need to specify the ODBC <em>data source</em> (the database from which you want retrieve data) by opening a connection to the database. Copy and paste the following script command: </li>
  311.  
  312. <pre><font size="3" face="courier">objConnection.Open<%
  313.   If ScriptLanguagePreference = "JScript" Then
  314. %>("ASPTutorial")<%Else%> "ASPTutorial"<% End If %> </font></pre>
  315.  
  316. <li>Use the Database Access component's <strong>Execute</strong> method to issue a Structured Query Language (SQL) <strong>SELECT</strong> command to the database and store the returned records in a result set (<font face="courier" size="3"><code>rsCustomersList</code></font>). Copy and paste the following script commands below the <font face="courier" size="3"><code>objConnection.Open</code></font> statement: </li>
  317.  
  318. <%
  319.   If ScriptLanguagePreference = "JScript" Then
  320. %><pre><font size="3" face="courier">rsCustomersList = objConnection.Execute("SELECT * FROM Customers")
  321. %></font></pre><%Else%><pre><font size="3" face="courier">SQLQuery = "SELECT * FROM Customers"  
  322. Set rsCustomersList = objConnection.Execute("SQLQuery")
  323. %></font></pre>
  324.  
  325.  
  326.  
  327. <% End If %>
  328.  
  329. <%
  330.   If ScriptLanguagePreference = "JScript" Then
  331. %><%Else%><p>You could combine these two lines of script by passing the literal SQL query string directly to the <strong>Execute</strong> method rather than
  332. assigning it first to the variable <strong>SQLQuery</strong>. When the SQL SELECT is long, however, it makes the script easier to read if you assign the string to a 
  333. variable name, such as <strong>SQLQuery</strong>, and then pass the variable name on to the <strong>Execute</strong> method. <!--</p>--><br><% End If %>
  334.  
  335. </ol>
  336.  
  337. <h3><a name="displaythereturnedresultset">Display the Returned Result Set</a></h3>
  338.  
  339. <p>You can think of the result set as a table whose structure is determined by the fields specified in the SQL <strong>SELECT</strong> statement. Displaying the rows returned by the query, therefore, is as easy as performing a loop through the rows of the result set. In this example, the returned data is displayed in HTML table rows. </p>
  340.  
  341. <ol>
  342.  
  343. <li>In Database.asp, find the words “<em>Tutorial Lesson - Display ADO Data</em>,” and copy and paste the following VBScript <strong>Do...Loop</strong> statement underneath the comment: </li>
  344. <pre><font face="courier" size="3"><% <%
  345.   If ScriptLanguagePreference = "JScript" Then
  346. %>while (!rsCustomersList.EOF) {<%Else%> Do Until rsCustomersList.EOF<% End If %>%>
  347.  
  348. <tr>
  349.   <td bgcolor="f7efde" align=center>
  350.     <%= rsCustomersList("ContactFirstName")%>  
  351.     <%= rsCustomersList("ContactLastName") %>
  352.   </td>
  353.   <td bgcolor="f7efde" align=center>    
  354.     <a href="mailto:<%= rsCustomersList("ContactLastName")%>">
  355.     <%= rsCustomersList("ContactLastName")%> </a>
  356.   </td>
  357.   <td bgcolor="f7efde" align=center>
  358.     <%= rsCustomersList("City")%>
  359.   </td>
  360.   <td bgcolor="f7efde" align=center>
  361.     <%= rsCustomersList("StateOrProvince")%>
  362.   </td>
  363. </tr> 
  364. </font></pre>
  365.  
  366. <p>If another user has previously completed this portion of the tutorial, this script command will already be in place. Paste the copied script over the existing script, or copy an unedited copy of Bayshore.asp from the Template directory to the Tutorial directory.</p>
  367.  
  368. <p>The <%=ScriptLanguagePreference%> <%
  369.   If ScriptLanguagePreference = "JScript" Then
  370. %> <strong>while</strong> loop<%Else%><strong>Do...Loop</strong><% End If %> statement repeats a block of statements while a condition is true. The repeated statements can be script commands 
  371. or HTML text and tags. Thus, each time through the loop, you construct a table row (using HTML) and insert returned data (using 
  372. script commands).</p>
  373.  
  374. <li>To complete the loop, use the <strong>MoveNext</strong> method to move the row pointer for the result set down one row. Because this statement still falls within the <strong>Do...Loop</strong> statement, it is repeated until the end of the file is reached. Copy and paste the following lines of script underneath the comment with the words “<em>Tutorial Lesson - Retrieve Next Row</em>”: </li>
  375.  
  376. <pre><font size="3" face="courier"><% 
  377. <%
  378.   If ScriptLanguagePreference = "JScript" Then
  379. %>rsCustomersList.MoveNext()
  380. }<%Else%>rsCustomersList.MoveNext 
  381. Loop<% End If %> 
  382. %></font></pre>
  383.  
  384. <li>Save changes to Database.asp as a text file and exit your text editor. Be sure your text editor does not replace the .asp file name extension.
  385. <br><br></li>
  386.  
  387. <li>To verify that the ASP page you’ve created works (after which you can return to this tutorial by clicking Back in your browser), point your browser to <a href="http://<%= Request.ServerVariables("SERVER_NAME")%>/iishelp/iis/htm/tutorial/database.asp"> http://<%= Request.ServerVariables("SERVER_NAME")%>/IISHelp/IIS/Help/Htm/Tutorial/Database.asp</a>.</li>
  388. </ol>
  389.  
  390. <h3><a name="onyourown2">On Your Own </a></h3>
  391.  
  392. <p>If you are using Windows NT, to see a more complete example of the Database Access component in action, visit the <a href="/iishelp/iis/htm/tutorial/linkchck.asp">Exploration Air</a> sample site.  Click the <strong>Behind the Scenes</strong> image to learn more about the scripts used to create this exciting Web site. The Bayshore Travel Web page also contains a link that can take you to the Exploration Air sample site.</p>
  393.  
  394. <p><strong>Note</strong>    If you have not yet visited the Exploration Air sample site, the preceding link will automatically redirect you to the Exploration Air home page. If this happens, use the <strong> Back </strong> button on your Web browser to navigate back to the tutorial and follow the link again.</p>
  395.  
  396. <p> Now that you've used ActiveX components, you may want to go on to <a href="iiatmd3.asp">Module 3: Writing Your Own  Components</a>. </p>
  397.  
  398. <hr class="iis" size="1">
  399. <p align=center><a href="../../../common/colegal.htm"><em>© 1997 Microsoft Corporation. All rights reserved.</em></a></p>
  400. </font>
  401. </body>
  402. </html>