将qul语句的数据存储在array7中 [英] store data of qul statment in a array7

查看:83
本文介绍了将qul语句的数据存储在array7中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在数组中存储查询的数据值(从雇员中选择emp_name)并在列表框中idsplay所有数据?

how to store data value of query (select emp_name from employee) in a array and idsplay all data in list box ?

推荐答案

DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(connectionString))
    {
    con.Open();
    using (SqlDataAdapter da = new SqlDataAdapter("SELECT emp_name FROM employee", con))
        {
        da.Fill(dt);
        }
    }
MyListBox.DataSource = dt;



使用此语句.此语句会将数据存储在结果"数组中.
Hi,
Use this.. This statement will store the data in "results" array.
DataTable docData= new DataTable();
using (SqlConnection con = new SqlConnection(connectionString))
{
    con.Open();
    using (SqlDataAdapter da = new SqlDataAdapter("SELECT emp_name FROM employee", con))
    {
        da.Fill(docData);
    }
}
//storing the datatable into multidimensional array
string[,] results = new string[doows.Count, docData.Columns.Count];

for (int rowCount = 0; rowCount < docData.Rows.Count; rowCount++)
{
  for (int colCount = 0; colCount < docData.Columns.Count; colCount++)
  {
    results[rowCount, colCount] = docData.Rows[rowCount][colCount].ToString();
  }
}


祝一切顺利.
--Amit


All the best.
--Amit


这篇关于将qul语句的数据存储在array7中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆