zoukankan      html  css  js  c++  java
  • (转)得到数据库中的某一列的所有值并将其存到数组中

    SqlConnection SqlConn = new SqlConnection("Server=.;Trusted_Connection=YES;DataBase=daigoudian");//创建数据库链接到daigoudian

            public void get_idstr(string[] str)
            {
                SqlDataAdapter Sqa = new SqlDataAdapter("Select id from daigoudian", SqlConn);
                DataSet ds = new DataSet();
                Sqa.Fill(ds);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];//得到行数据集,实际是个数组……
                    str[i] = dr.ItemArray[0].ToString();
                }
            }//获取所有列id 的值并存入数组str中

  • 相关阅读:
    协成
    进程与线程-多线程
    进程与线程2
    进程与线程
    socket编程
    常用模块二(hashlib、configparser、logging)
    异常处理
    python之路——面向对象进阶
    封装
    初识——面向对象
  • 原文地址:https://www.cnblogs.com/jinqier/p/3413656.html
Copyright © 2011-2022 走看看