Convert Linq.DataQuery to DataTable

J

JDS

I am trying to pass a set of data produced using Linq to a method
requiring a System.Data.DataTable argument. I have tried the
following:

Dim qMaterials = From m in mdbMaterials Select m
Dim dtMaterials As New DataTable
dtMaterials = CType(qMaterials, DataTable)

but I get an error message "Unable to cast object of type ....".

(I can't use Linq in the receiving method because that needs to run
under .Net 2.0).

Is there an easy way to convert a result set from a Linq query to a
DataTable type? Or an alternative solution? (or have I missed the
point?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top