TotalWhat Posted January 20, 2015 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 Link to comment Share on other sites More sharing options...
davej Posted January 20, 2015 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 Link to comment Share on other sites More sharing options...
TotalWhat Posted January 26, 2015 Author 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.. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 26, 2015 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now