当前位置: 首页 > 图文教程 > 网络编程 > ASP > 将ASP代码移植为VB COM组件-4

ASP
asp+语法教程(三)asp+的服务器端编程初步
asp+语法教程(四)asp+的服务器端编程进介
asp+语法教程(五)asp+的服务器端编程控件篇
asp+语法教程(六)数据库篇
从ASP迁移至ASP+
从ASP迁移至ASP+ --进入DataSet
从ASP迁移至ASP+ --HTML表格转换为ASP+列表
从ASP迁移至ASP+ --转换其他的页面
从ASP迁移至ASP+ --处理会话变量
ASP十步进阶
asp.net高级教程(一)-asp.net还是asp+ ?
asp.net高级教程(二)- 转换编程思维
asp.net高级教程(三)-对象
asp.net高级教程(三)-实战篇
asp.net高级教程(五)-实战篇(中)
ASP+中文教程(一)--asp+简介、安装、以及如何显示中文
asp+中文教程(二)-- Asp+ Web Forms
APS + 中文教程(三)--服务器端控制(一)
SQL数据操作基础(初级) 4
SQL数据操作基础(初级) 5

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 67 ::
收藏到网摘: n/a

  这个例子中的第一站是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
% >