TotalWhat 0 Posted January 20, 2015 Report Share Posted January 20, 2015 (edited) Hello everyone! So I have a webservice that I made in C# that use DataTable, this works fine in my .net application which can consume DataTable. But I can't use it in my java application. So I need a way to convert the DataTable to a List when the java application use the webservice. Could anyone help me out? Edited January 26, 2015 by TotalWhat Quote Link to post Share on other sites
davej 251 Posted January 20, 2015 Report Share Posted January 20, 2015 I would think it would be better to produce data in XML or JSON format for a web service. See... https://msdn.microsoft.com/en-us/library/system.data.datatable.writexml.aspx Quote Link to post Share on other sites
TotalWhat 0 Posted January 26, 2015 Author Report Share Posted January 26, 2015 I've gotten this far: public List<List<string>> Convert(DataTable dataTable) { var result = List<List<string>>; // Loop over all the rows foreach (var row in DataTable.Rows) { var newRow = List<string>; // Loop over all the cells foreach (var cell in row.Cells) { newRow.Add(cell.ToString()); } result.Add(newRow); } return result; } But it doesent work and I'm not sure how to finish it. Not even sure if it would be able to do what I want it to do. That is to convert a datatable to a list.. Quote Link to post Share on other sites
justsomeguy 1,135 Posted January 26, 2015 Report Share Posted January 26, 2015 foreach (var row in DataTable.Rows)Is that supposed to be uppercase or lowercase? It's a little confusing when you use data types as variable names. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.