Die allgemeine Weise, Daten von einem recordset anzuzeigen, ist, die Daten in einer HTML Tabelle anzuzeigen.
Die Feldnamen anzeigen und Werte auffangen
Wir haben eine Datenbank, die �vyom� genannt wird und wir m�chten die Daten von der �Angestellt� Tabelle anzeigen, die wir die Akte mit einer .asp Verl�ngerung speichern.
<html>
<head>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/vyomworld/vyom.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT * FROM employee", conn
do until rs.EOF
for each x in rs.Fields
Response.Write(x.name)
Response.Write(" = ")
Response.Write(x.value & "<br />")
next
Response.Write("<br />")
rs.MoveNext
loop
rs.close
conn.close
%>
</head>
</html>
Output: Display as--
EmloyeeID = Sys04
CompanyName = Vyom Technosoft
ContactName = Raj
ContactTitle = Developer
Address = STPI-Block3
City = Electronic city
PostalCode = 560100
Country = India
EmloyeeID = Sys03
CompanyName = Vyom Technosoft
ContactName = Rajeev
ContactTitle = Developer
Address = STPI-Block3
City = Electronic city
PostalCode = 560100
Country = India
EmloyeeID = Sys01
CompanyName = Vyom Technosoft
ContactName = Raju
ContactTitle = System Admin
Address = silicon vally
City = Electronic city
PostalCode = 560100
Country = India
Display the Field Names and Field Values in an HTML Table
We can display the data from the "Emloyee" table inside an HTML table with the following lines and save the file with an .asp extension.
<html>
<head>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/vyomworld/vyom.mdb"
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT Companyname, Contactname FROM employee", conn
%>
<table border="1" width="100%">
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
>/tr>
<%loop
rs.close
conn.close
%>
</head>
</html>
Output: Display as--
Vyom
Rajeev
Royal Soft
Sedan
IT Tech
Grayan
Global IT
T koock
Soft Uro
Dol Gerg
Tera Soft
Rana
RevaTech
Peter Ron
MicroSolution
Kurdin
TenSoftware
Waren
Riya Chemical
Revan
Riyan Hardware
Rojon
BangaSoft
Surab
ZSoft
Wallan
TechSoft
Prasie
RoyTech Group
Hrosod
Silicon Tech Group
Jupit
Big International
Partijar
Die Feldnamen anzeigen und Werte in einer HTML Tabelle auffangen
Wir k�nnen die Daten von der �Emloyee� Tabelle innerhalb einer HTML Tabelle mit den folgenden Linien anzeigen und die Akte mit einer .asp Verl�ngerung speichern.
<html>
<head>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/vyomworld/vyom.mdb"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT Companyname, Contactname FROM Employee"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close