views:

220

answers:

1

Hi,

What will the best way to pass a datatable data to unmanaged environments? (c++)

Ofer

+1  A: 

I don't think there is a single best answer here.

One option is to export the database as XML and let your unmanaged code consume that. The main benefit of this approach is it is cheaper (development-wise) on the managed side and provides flexibility on the unmanaged side.

Otherwise you will need to provide your own marshaling of the data. This would be best down with C++/CLI code that could work with the dataset and convert it to a data structure that your unmanaged code understands.

We've done something similar in the past and it works, but is a fair amount of code to cover the general case.

Rob Walker