The first error made me think that this was caused by an invalid character in my data, which was being returned from a webservice to my data in my program.
I took a copy of what was being returned using "fiddler" to see what was going on in my browser - it showed the xml being returned was fine. I even validated the XML to check.
The interesting thing was the inner exception of "DataTable does not match to any DataTable in source." thrown in Visual Studio. Looking at this, it was telling me that the datatable being returned from the webservice, was not the same as the datatable I had in Visual Studio. The strange this was, they were both typed datatables! so how could they be wrong.... well, they weren't.
The source of the problem was the following which was at position 1994 in the XML:
"diffgr:diffgram msdata="urn:schemas-microsoft-com:xml-msdata" "
This was telling me that there was a difference in the schema of the dataset... <- Note here, a difference in the DATASET. I was not returning a dataset, I was returning a datatable! Anyway, a quick google brought up a nice little link from the good boys at Microsoft:
{
MyTypedDataSet ds = new MyTypedDataSet();
MyTypedDataTable dt = aFunctionThatGetsTheData(someparams);
Thank you for your post! I got the same problem with WCF. And resolved it only with helping of your post!
ReplyDeleteYou are more than welcome!
ReplyDeleteYou can return a DataTable from a web service, you just need to make sure the TableName is set.
ReplyDeleteThank u very much
ReplyDelete