Jump to content

Converting DataTable to List


TotalWhat

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...