RecordSet是另一個創建/安排對象。它是從數據庫中獲取的數據集合。 RecordSet具有26個屬性,25種方法,11個事件和兩個(2)個集合。絕大多數記錄集都超出了該網站的範圍。
快速一邊:
我們用於第16課的數據庫和第17課是MS Access 2000文件(不是大型站點的最佳數據庫)。該文件稱為htmlcolor.mdb,它具有一個稱為colorchart的單個表。數據庫表有三個列,它們稱為ID,colorname和Hexvalue。
下圖顯示了我們將如何循環瀏覽這些記錄。
|
|
|
在此示例中,我們按行循環循環。我們將使用movenext()方法從記錄#1到#2等。然後,我們將使用列名訪問每行的特定數據。
開始:
以下是第17課的腳本。它與第16課的腳本完全相同。不同之處在於,我們將重點關注與記錄集有關的代碼行。
<%@語言=“ javascript”%> <! - metadata type =“ typelib” file =“ c:/program files/common Files/common files/system/ado/msado15l” - > <html> <html> <body> <body> <%var myconnect =“ provider = microsoft.jet.jet.jet.oled.oledb.4.0; data source; data source; data source; data source; data source; data source; myConnect += server.mappath(“ //”); myConnect +=“ ///globalscripts//htmlcolor.mdb;“; var connectObj = server.creat.createobject(“ adodb.connection”) colorChart;“; connectObj.open(myConnect); rs.open(sql,connectObj,andyenforwardonly,adlockReadonly,adcmdText); wrespons.write.write(“ <table border =/” 1/“” cell -spacing =/“ 0/”>/r“); wress.write(“ <tr> </th> </th> <th> colorname </th>”); response.write(“ <th> hexvalue </th> </th> </tr>/r”); while(!rs.eof){! bgcolor =/“#”); wress.write(rs(“ hexvalue”) +“/”>“ + rs(“ colorname”)); wrespy.write(“ </td> <td> <td>” + rs(“ hexvalue”) + “ </td> </tr>/r”); rs.Movenex();} response.write(“ </table>/r”); rs.close(); connectObj.close(); rs = null; connectObj = null; connectObj = null;%> </body> </hody> </html> </html> </html> </html> </html> </html> </html> </html> </html> </html> </html> </html>