欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

asp页面
作 者 : 青苹果电脑工作室                                    本文点击次数:351

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 将ASP代码移植为VB COM组件(转4)
分享到: 更多 (0)