快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

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

这个例子中的第一站是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
% >
返回类别: 教程
上一教程: 一个简朴的ASP分页程序
下一教程: 利用COOKIE收藏网站

您可以阅读与"将ASP代码移植为VB COM组件-4"相关的教程:
· 将ASP代码移植为VB COM组件-3
· 将ASP代码移植为VB COM组件-2
· 将ASP代码移植为VB COM组件-1
· 调试 ASP 中使用的 VISUAL BASIC COM 组件
· 手把手教你使用VB来创建ASP组件(6)
    微笑服务 优质保证 索取样品