Jump to content

Converting DataTable to List

Recommended Posts

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 by TotalWhat
Link to post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...