将数据集转换为数据表 [英] convert dataset to datatable
本文介绍了将数据集转换为数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
下面是我的示例代码,我将数据导入数据集。
现在我要将其转换为dataTable。
请帮我解决这个问题。
Hi all
Below is my sample code where i am getting the data into a dataset.
Now i want to convert this to a dataTable.
Please help me how to do that.
DataSet Obj_DS_VNXRpt = new DataSet();
Obj_DS_VNXRpt.Tables.Add(Obj_DT_LogAlerts);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_HwFailure);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_StorageInfo);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_RepliStatus);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_SyncTime);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_FilesysStatus);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_DiskFailures);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_TresspassLun);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_FileTage);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_FileHealthCheck);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_BLStorageStatus);
Obj_DS_VNXRpt.Tables.Add(Obj_DT_BLLogAlerts);
推荐答案
数据集和数据表是不同的东西。数据表就像一个Excel工作表,包含单个表的数据,因此具有列,约束等。
数据集然后再次是一个集合数据表。数据集本身不包含数据,但它包含数据表之间的关系和约束。同样相应的Excel对象将是一个工作簿。
换句话说,您无法将数据集转换为数据表,因为单个数据集可以包含多个表,如你的例子。
A data set and a data table are different things. A data table is like an Excel worksheet containing data for a single table, thus having columns, constraints, and so on.
A data set then again is a collection of data tables. The data set doesn't contain the data by itself but it contains relations and constraints between the data tables. Again the corresponding Excel object would be a workbook.
In other words you cannot convert a data set to a data table since a single data set can contain multiple tables as in your example.
简单地说:
Do Simply:
DataTable customerTable = Obj_DS_VNXRpt.Tables[0];
希望有所帮助:)
Hope it helps :)
这篇关于将数据集转换为数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文