ASP -Seite
Autor: Qing Apple Computer Studio Klick: 351
Der erste Stopp in diesem Beispiel ist die ASP -Seite. Diese ASP -Seite ist mit der ADO- und Northwind -Datenbank verbunden. Um eine gute Codierungsgewohnheit aufrechtzuerhalten, habe ich
Option Explizit wurde verwendet und alle Variablen klar deklariert. Der erste Entwurf dieser ASP -Seite verwendet den inneren Code.
< % @ Sprache = vbscript %>
< %
'Beispiel für Inline -Code
Option explizit
'Variablen deklarieren
Dim Oconn
Dim ORS
Dim ConnectionString
Dim x
connectionString = dsn = nordwind;
Setzen Sie oconn = server.createObject (adodb.Connection)
oconn.open ConnectionString
setRs = server.createObject (adodb.oldset)
'Variablen einstellen
ONDECONNECTION = OCONN
c c c c c c
Ond.open
%>
<html>
<kopf>
<meta http-äquiv = content-type content = text/html;
<titels> Neue Seite 1 < /title>
< /head>
<body>
<h1> Produkte < /h1>
<Table Cellspacing = 2 Cellpadding = 5>
<trbgcolor =#ff6666>
<Th> Produktname < /th>
<Th> Menge pro Unitr < /th>
<Th> Preis < /th>
< /tr>
< %
mach Unil om.eof
Wenn x = 1 dann
x = 0
%>
<trbgcolor =#ffcccc>
< % Sonst %>
<tr>
< %
x = 1
Ende wenn
%>
<td> < % = ors (productName) %> < /td>
<td> < % = ors (quantityperunit) %> < /td>
<td> < % = ors (UnitPrice) %> < /td>
< /tr>
< %
ONDEDEXT
Schleife
%>
< /table>
< /body>
< /html>
< %
'Zerstöre Objekte
setrs = nichts
Setzen Sie Oconn = nichts
%>