繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> 组件开发 >> 将ASP代码移植为VB COM组件(4)

将ASP代码移植为VB COM组件(4)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:14  文字大小:【】【】【
简介:ASP页面 作 者 : 青苹果电脑工作室 这个例子中的第一站是ASP页。这个ASP页用ADO与Northwind 数据库连接。为了保持良好的编码习惯,我 使用了Option Explicit 并明确地声明了所有变量。这个ASP页的第一个草...
关键字:移植 组件 代码 COM ASP

ASP页面

作 者 : 青苹果电脑工作室

这个例子中的第一站是ASP页。这个ASP页用ADO与Northwind 数据库连接。为了保持良好的编码习惯,我

使用了Option Explicit 并明确地声明了所有变量。这个ASP页的第一个草稿使用了内联代码。

< % @ 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 >

< /head >

< body >

< h1 >Products< /h1 >

< 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 >

< /html >

< %

'Destroy objects

Set oRS = Nothing

Set oConn = Nothing

% >

责任编辑:admin
相关文章