Porting ASP code to VB COM component (ext. 4)

Source: Internet
Author: User
Tags variables
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
% >



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.