• ASP和ASP.net中多结果集的返回


    <%
    '
    '
        Made by Goodspeed
    '
    '
        
    Option Explicit 
    Response.Buffer 
    = True
    'sql数据库连接参数:数据库名、用户密码、用户名、连接名(本地用local,外地用IP)
    Const SqlUsername = "sa"
    Const SqlPassword = "qwe"
    Const SqlDatabaseName = "NorthWind"
    Const SqlLocalName = "127.0.0.1"
    Dim ConnStr

    ConnStr 
    = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"

    '打开数据库
    Dim Conn
    Set Conn=server.createobject("adodb.connection")
    Conn.Open ConnStr
    %
    >
    <html>
    <head>
        
    <title>ASP Test</title>
        
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body>
    <table>
    <%
    Dim rs, rs1,strSQL, Field, strResponse,cmd,rs2

    Set rs = Server.CreateObject("ADODB.Recordset"'建立记录集对象 
    Set cmd = Server.CreateObject("ADODB.Command"'建立命令对象
    set cmd.ActiveConnection=Conn
    cmd.CommandText
    ="aaa"
    cmd.CommandType = 4 '命令类别为4,表示为存储过程 

    set rs =cmd.execute

    Do Until rs is nothing

        
    '输出表头
        strResponse = "<tr>"
        For Each Field In rs.Fields
            strResponse 
    = strResponse & "<td>" & Field.Name & "</td>"
        Next
        strResponse 
    = strResponse & "</tr>"

        '输出表体
        Do Until rs.EOF
            strResponse 
    = strResponse & "<tr>"

            For Each Field In rs.Fields
                strResponse 
    = strResponse & "<td>" & rs(Field.Name)  & "</td>"
            Next
            
            strResponse 
    = strResponse & "</tr>"
            rs.MoveNext
        
    Loop
        
    Set rs = rs.NextRecordset()
    Loop
    Set rs = nothing
    Response.Write (strResponse)
    %
    >
    </table>
    </body>
    </html>
    <%
    Conn.Close()
    Set Conn = nothing
    %
    >
    <script runat="server">

        
    void Page_Load(object sender, EventArgs e)
        
    {
            System.Data.DataSet ds 
    = SqlHelper.ExecuteDataSet("aaa");

            GridView1.DataSource 
    = ds.Tables[1];
            GridView1.DataBind();
        }

    </script>
  • 相关阅读:
    135编辑器使用教程
    gitalb的搭建与使用
    关于String类型,转换BigDecimal .并且BigDecimal 的乘法计算
    关于MAP转换成驼峰命名法然后转换成实体
    java时间计算,获取某月第一天和最后一天
    Spring 自带的定时任务
    Hibernate jpa 在实体类中对于时间的注解
    noip2014总结
    sroHOBOorz来自HOBO的高精类
    2014年9月6日
  • 原文地址:https://www.cnblogs.com/goodspeed/p/42632.html
Copyright © 2020-2023  润新知