zoukankan      html  css  js  c++  java
  • datatable与dataset加二维数组实现

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Data.OleDb;

    public partial class reader : System.Web.UI.Page
    {
        const string connStr = "data source=127.0.0.1;user id=sa;password=***;initial catalog=***";
        SqlConnection conn;
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            conn = new SqlConnection(connStr);
            string sql = "select * from t_type";
            
            SqlCommand cmd;
            cmd = conn.CreateCommand();
            
            
            cmd.CommandText = sql;
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader();//这个是为了循环的
            DataTable dataTable = new DataTable();
            dataTable.Load(reader);
            string[,] rdrString = new string[dataTable.Rows.Count, 2];
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    rdrString = dataTable.Rows[j].ToString();
                }
            }
            reader.Close();
            foreach (string temp in rdrString)
            {
                this.Label1.Text += temp + "<br>";
            }
        }
    }
  • 相关阅读:
    一些有用的正则
    UNION ALL合表查询
    远程桌面连接:出现身份验证错误,要求的函数不受支持,可能是由于CredSSP加密Oracle修正的解决方法
    Ubuntu20.04安装、配置openvas
    awvs13破解安装、批量扫描脚本
    剑指05题
    时间复杂度o(1), o(n), o(logn), o(nlogn)
    Intellij IDEA 注释模板
    Explain详解
    Hibernate中get()和load()的区别
  • 原文地址:https://www.cnblogs.com/mokliu/p/2138943.html
Copyright © 2011-2022 走看看