ASP page
Author: Green Apple Computer Studio This article hits: 351
The first stop in this example is the ASP page. This ASP page is connected to the Northwind database with ADO. In order to maintain good coding habits, I
The option Explicit is used and all variables are explicitly declared. The first draft of this ASP page uses an inline code.
<% @ Language=vbscript% >
<%
' Example of Inline code
Option Explicit
' Declare variables
Dim oconn
Dim ORS
Dim ConnectionString
Dim x
ConnectionString = "Dsn=northwind;"
Set oconn = Server.CreateObject ("ADODB. Connection ")
oConn.Open ConnectionString
Set ORS = Server.CreateObject ("ADODB. Recordset ")
' Set variables
Ors.activeconnection = oconn
Ors.source = "SELECT * FROM Products"
oRS.Open
% >
< HTML >
< head >
< meta http-equiv= "Content-type" content= "text/html; charset=windows-1252 ">
< title >new Page 1</title >
< BODY >
< H1 >Products
< table cellspacing= "2" cellpadding= "5" >
< tr bgcolor= "#FF6666" >
< th >product name</th >
< th >quantity per unitr</th >
< th >Price</th >
</tr >
<%
Do Until ors.eof
If x = 1 Then
x = 0
% >
< tr bgcolor= "#ffcccc" >
<% Else% >
< tr >
<%
x = 1
End If
% >
< TD ><%=ors ("ProductName")% ></td >
< TD ><%=ors ("QuantityPerUnit")% ></td >
< TD ><%=ors ("UnitPrice")% ></td >
</tr >
<%
Ors.movenext
Loop
% >
</table >
</body >
<%
' Destroy objects
Set ORS = Nothing
Set oconn = Nothing
% >