หน้า ASP
ผู้แต่ง: Qing Apple Computer Studio คลิก: 351
จุดแรกในตัวอย่างนี้คือหน้า ASP หน้า ASP นี้เชื่อมต่อกับฐานข้อมูล ADO และ Northwind เพื่อรักษานิสัยการเข้ารหัสที่ดีฉัน
ตัวเลือกถูกนำมาใช้อย่างชัดเจนและประกาศตัวแปรทั้งหมดอย่างชัดเจน ร่างแรกของหน้า ASP นี้ใช้รหัสด้านใน
< % @ language = vbscript %>
-
'ตัวอย่างของรหัสอินไลน์
ตัวเลือกอย่างชัดเจน
'ประกาศตัวแปร
หรอก oconn
สลัวหรือ
การเชื่อมต่อสลัว
สลัว x
ConnectionString = dsn = Northwind;
ตั้งค่า oconn = server.createObject (adodb.connection)
Oconn.open ConnectionString
setRs = server.createObject (adoDb.oldset)
'ตั้งค่าตัวแปร
onDeconnection = oconn
C C C C
ond.open
-
<html>
<head>
<meta http-equiv = เนื้อหาประเภทเนื้อหา = text/html;
<title> หน้าใหม่ 1 </title>
</head>
<body>
<H1> ผลิตภัณฑ์ </h1>
<Table CellSpacing = 2 CellPadding = 5>
<trbgColor =#ff6666>
<th> ชื่อผลิตภัณฑ์ </th>
<th> ปริมาณต่อหน่วย </th>
<th> ราคา </th>
</tr>
-
ทำ unil om.eof
ถ้า x = 1 แล้ว
x = 0
-
<trbgColor =#ffcccc>
< % อื่น %>
<tr>
-
x = 1
สิ้นสุดถ้า
-
<td> < % = ors (ชื่อผลิตภัณฑ์) %> </td>
<td> < % = ors (ปริมาณ perunit) %> </td>
<td> < % = ors (unitprice) %> </td>
</tr>
-
ondenext
วง
-
</table>
</body>
</html>
-
'ทำลายวัตถุ
setrs = ไม่มีอะไร
ตั้งค่า oconn = ไม่มีอะไร
-