I have a dataset containing some datatables, now i want to fetch a datatable from db and add it to the existing datatable in dataset i am using below line
return (DataSets.General.StudentDataTable) ds.Tables["DSDummy"];
But its giving me following error
Cannot implicitly convert type ‘System.Data.DataTable’ to
DataSets.General.StudentDataTable’. An explicit conversion exists
can someone please tell me how to cast this object? any help would be appreciated
Thanks
If
dsis a strongly typed dataset, I would expect it to have an explicit property for the DSDummy table, something likeds.DSDummy, rather than going through theTablescollection, which bypasses the strong typing.However, even as it stands, the explicit cast should have worked. Is it possible that you have
DataSets.General.StudentDataTabledefined more than once – once manually and once automatically from the DataSet Generator – and it’s conflicting?