logo 广告
Loading...
 导航 所在位置:论坛首页 -> ┈┋电脑网络┋┈ -> Asp/Asp.Net教程 -> 将ASP代码移植为VB COM组件-4
回复
标题:将ASP代码移植为VB COM组件-4收藏 编辑 删除 楼主 | 上一篇 下一篇
小糊涂神
头像
等级:社区游民
权限:管理员
积分:3
金钱:4481
声望:9
经验:9
发帖数:2150
注册:未知
资料 短消息2006-6-25 16:58:00

  这个例子中的第一站是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
% >   
签名
有肚量去容忍那些无法改变的事情
有勇气去改变那些可以改变的事情
有智慧去区别上述二类事

2006-6-25 16:58:00 顶部
第1页 共页 共0个回复     <<    >>    
 快速回复
  • 支持UBB,HTML标签

  • 高级回复

  • 操作选项:评分 加精 解精 奖惩 设专题 设公告 解公告 固顶 总固顶 解固顶 结帖 解结帖 锁帖 解锁 移帖 删帖
      首页 | 购买指南 | 虚拟主机 | 特色介绍 | 下载中心 | 支付方式
    Copyright 2004-2008 BBSGood.com Powered By: BBSGood.Speed Version 5.0
      咨询电话:0575-85513832、0575-85513825(传真)、7*24小时咨询服务:13606552007 不良信息举报中心 浙ICP备05029817号
      业务QQ:38958768、客服QQ1:415896239、客服QQ2:343896043、MSN:jccsxx@hotmail.com