zoukankan      html  css  js  c++  java
  • DataReader对象

    DataReader对象用于从数据库中获取仅向前的只读数据流,由于在内存一次只存放一行数据,因此使用DataReader对象可提高应用程序的性能,大幅度减少对内存的需求。
    protected void Page_Load(object sender, EventArgs e)
        {
            OleDbConnection conn 
    = new OleDbConnection();
            conn.ConnectionString 
    = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                
    "Data Source=" + Server.MapPath("person.mdb");
            conn.Open();
            
    string strSQL = "select * from grade";
            OleDbCommand Comm 
    = new OleDbCommand(strSQL, conn);
            OleDbDataReader dr 
    = Comm.ExecuteReader();
            
    string html = "<table border=1>";
            html 
    += "<tr>";
            html 
    += "<td><b>学号</b></td>";
            html 
    += "<td><b>姓名</b></td>";
            html 
    += "<td><b>数学</b></td>";
            html 
    += "</tr>";
            
    try
            {
                
    while (dr.Read())
                {
                    html 
    += "<tr>";
                    html 
    += "<td>" + dr["学号"].ToString() + "</td>";
                    html 
    += "<td>" + dr["姓名"].ToString() + "</td>";
                    html 
    += "<td>" + dr["数学"].ToString() + "</td>";
                    html 
    += "</tr>";
                }
                html 
    += "</table>";
            }
            
    finally
            {
                dr.Close();
                conn.Close();
            }
            Response.Write(html);
        }
  • 相关阅读:
    在SSM框架中,multfile转file
    mysql 存储过程简单实例
    mysql 对比两个表的一致性
    Lucene 排序 Sort与SortField
    Lucene5.x 中文 同义词
    Lucene分页-----SearcherAfter
    Lucene的Query类介绍
    二叉树实例学习(四)——获取节点的高度函数getHight()
    二叉树实例学习(三)——插入左右节点函数测试
    二叉树实例学习(二)
  • 原文地址:https://www.cnblogs.com/qixin622/p/756630.html
Copyright © 2011-2022 走看看