Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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.

C#
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);
Posted
Comments
Thanks7872 14-Aug-15 6:16am    
You are adding all the DataTables to dataset then you have access to all the tables. What is the issue? You can easily access them. As per as the conversion is concerned, its not possible. DataSet is set of Datatables and thats the reason in above code you are adding datatables to dataset.

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.
 
Share this answer
 
Comments
Black_Rose 14-Aug-15 6:05am    
Any solution for this..??
Wendelius 14-Aug-15 6:13am    
As I explained data set and data table are different. What is it you're trying to achieve?
Do Simply:

C#
DataTable customerTable = Obj_DS_VNXRpt.Tables[0];


Hope it helps :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900