Recordset is another created/instanciated Object. It is a collection of data taken from a database. Recordset has 26 properties, 25 methods, 11 events, and two (2) collections. The vast majority of Recordset is beyond the scope of this web site.
Quick Aside:
The database we are using for lesson 16 and lesson 17 is an MS Access 2000 file (not the best database for large sites). The file is called htmlColor.mdb and it has a single Table called colorChart. The database Table has three columns and they are called ID, colorName, and hexValue.
The illustration below shows how we will cycle through these records.
In this example we cycle through the records row by row. We will use the MoveNext() Method to go from record #1 to #2, etc. Then, we will access specific data in each row by using the column name.
Get Started:
Below is the script for Lesson 17. It's exactly the same as the script for lesson 16. The difference is that we will focus on those lines of code that deal with Recordsets.
<%@LANGUAGE="JavaScript"%> <!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" --> <HTML> <BODY> <% var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="; myConnect += Server.MapPath("\\"); myConnect += "\\GlobalScripts\\htmlColor.mdb;"; var ConnectObj = Server.CreateObject("ADODB.Connection"); var RS = Server.CreateObject("ADODB.Recordset"); var sql="SELECT ID, colorName, hexValue FROM colorChart;"; ConnectObj.Open (myConnect); RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText); Response.Write("<TABLE BORDER=\"1\" CELLSPACING=\"0\">\r"); Response.Write("<TR><TH>ID</TH><TH>colorName</TH>"); Response.Write("<TH>hexValue</TH></TR>\r"); while (!RS.EOF) { Response.Write("<TR><TD>" +RS("ID")+ "</TD><TD BGCOLOR=\"#"); Response.Write( RS("hexValue")+ "\">" + RS("colorName") ); Response.Write("</TD><TD>" +RS("hexValue")+ "</TD></TR>\r"); RS.MoveNext(); } Response.Write("</TABLE>\r"); RS.Close(); ConnectObj.Close(); RS = null; ConnectObj = null; %> </BODY> </HTML>
Click Here to run the script in a new window.
The DLL:
We'll dissect the Recordset statements from top to bottom. In this case that means starting with the Dynamic Link Library.
<!-- METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
What in the world is a DLL? A Dynamic Link Library holds values without tying up memory. Here's how it works. If you try to use a variable that is undefined, ASP will first look it up in the DLL. You'll notice in the
Managing the Recordset:
First we must instanciate a Recordset, which we do in the little snippet below.
var RS = Server.CreateObject("ADODB.Recordset");
Next we create a Text Command. The text in question comes in the form of S.Q.L. (Structured Query Language). SQL is beyond the scope of this web site, but the command below means select ID, colorName and hexValue from the colorChart Table.
var sql="SELECT ID, colorName, hexValue FROM colorChart;";
Then we open the Recordset. The five arguments in order are: source, connection, cursor type, lock type, and options .
RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText);
Using a loop, we tell ASP to do certain things for as long as we haven't hit EOF, which means End of File.
while (!RS.EOF)
Next, we access specific collums in the Recordset by name.
Response.Write( RS("hexValue") + "\">" + RS("colorName") );
Then we move down from one row of records to the next.
RS.MoveNext();
Finally, when we reach EOF, the loop relinquishes control and we can close the Recordset Object.
RS.Close();
The Rest of The Story:
This is by no means a complete lesson on Recordsets; it wasn't meant to be. The rest of the story on Recordsets is out there, on the internet, and in books. There is one other thing we have to talk about with Recordsets. We do that in lesson 18.
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 群星《2024好听新歌36》AI调整音效【WAV分轨】
- 梁朝伟.1986-朦胧夜雨裡(华星40经典)【华星】【WAV+CUE】
- 方芳.1996-得意洋洋【中唱】【WAV+CUE】
- 辛欣.2001-放120个心【上海音像】【WAV+CUE】
- 柏菲·万山红《花开原野1》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 柏菲·万山红《花开原野2》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 潘安邦《思念精选集全纪录》5CD[WAV+CUE]
- 杨千嬅《千嬅新唱金牌金曲》金牌娱乐 [WAV+CUE][985M]
- 杨钰莹《依然情深》首版[WAV+CUE][1G]
- 第五街的士高《印度激情版》3CD [WAV+CUE][2.4G]
- 三国志8重制版哪个武将智力高 三国志8重制版智力武将排行一览
- 三国志8重制版哪个武将好 三国志8重制版武将排行一览
- 三国志8重制版武将图像怎么保存 三国志8重制版武将图像设置方法
- 何方.1990-我不是那种人【林杰唱片】【WAV+CUE】
- 张惠妹.1999-妹力新世纪2CD【丰华】【WAV+CUE】