Click here to Skip to main content
15,036,363 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
Session[StringConstants.DTRefTransactions] = dsRefTransactions.Tables[0];


getting error as unable to cast object of type 'system.data.datatable' to type 'system.data.dataset' on above line of code . how to type cast it?
Posted
Updated 8-Nov-11 3:04am
v2
Comments
   
Can you read the error message?
Why do you think you want to cast it?
--SA

You cannot. A DataTable is not a DataSet.
   
Comments
durgeshtupkar10 8-Nov-11 9:10am
   
what solution then?
   
Enough said, a 5.
--SA
Abhinav S 8-Nov-11 11:24am
   
Thanks SA.
You can't cast a DataTable to a DataSet. It sounds like your code is expecting a DataSet so you could try:

C#
Session[StringConstants.DTRefTransactions] = dsRefTransactions;
   
Comments
durgeshtupkar10 8-Nov-11 9:17am
   
but on following ur above suggestion it works but i want oth index datatable from that datasetparticular
jim lahey 8-Nov-11 9:19am
   
You've got the whole dataset in session. You can read it back out of session and do: dsRefTransactions.Tables[0]
   
No ifs no buts.
--SA
   
Sure, a 5. OP cannot apply simple logic.
--SA

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