How can I convert database query results to an array?

前端 未结 4 602
一向
一向 2021-01-23 07:59

How would I convert the results returned in a MySQL query to an array in C# .Net/Mono

To my understanding you need to define arrays with the number of items the array wi

4条回答
  •  一向
    一向 (楼主)
    2021-01-23 08:24

    Instead of using a DataReader, use a DataAdapter to fill a DataTable. You can see the total number of rows in the resulting DataTable.

    var results = new DataTable();
    
    var adapter = new SqlDataAdapter();
    adapter.SelectCommand = dbcmd;
    dapater.Fill(results);
    

提交回复
热议问题