0

Bit out of my depth on this one! I have a DataSet designed in the DataSet designer. I import/export data via an xml file. Thus, I don't use a data connection, and thus can't figure out how to build queries (as these appear to require a table adaptor, which in turn require a data connection).

So trying to build queries via joins via LINQ. Abridged code:

    Imports System.Data
    Imports System.Linq

        Public Class Configuration

            Public FullSystem As New DataTable

             Private Sub Configuration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                    call ConstructQueryTables()
            End Sub

            Private Sub ConstructQueryTables()
                Dim GEEmus As DataTable = GemDSConfig.Tables("UserEmulators")
                Dim SysSetups As DataTable = GemDSConfig.Tables("SystemsSetups")

                Dim query = From SysSetup In SysSetups.AsEnumerable() From GEEmu In GEEmus.AsEnumerable() _
                    Where SysSetup.Field(Of Integer)("UserEmuID") = GEEmu.Field(Of Integer)("ID")
                    Select SysSetup

                FullSystem = query.copytodatatable()

            End Sub

        end class

and resulting error:

System.MissingMemberException: Public member 'copytodatatable' on type 'WhereSelectEnumerableIterator(Of VB$AnonymousType_0(Of DataRow,DataRow),DataRow)' not found.

From reading, it appears that this is something to do with how Select returns the data (not in DataRow format) and that copytodatatable requires it in DataRow format. I've tried following the marked solution here.

But, the first didn't work and the second (object shredder) was a bit beyond my level (I couldn't figure how to use the code in the linked MS article).

Stumped on this one:

1) It feels that it may be better to be able to maipulate my DataSet via queries, but can't figure how to use data connecitons with my setup as described above. Would it be better and if so, how to achieve?

2) If above not applicable, how can I get linq query results returned to a data table? I'm just starting out, so the MS link above was a bit beyond my comprehension. I do have my code uploaded to codeplex.

thanks

Community
  • 1
  • 1
stigzler
  • 793
  • 2
  • 12
  • 29
  • Seems like that should work based on the accepted answer. Are you sure you are using .NET 3.5+? I would change the case to .CopyToDataTable() as well (but I'm used to C#). – Robert McKee Dec 13 '15 at 07:09
  • No option for "3.5+" in Visual studio - only 3.5. Also - changed case - made no difference - same error. – stigzler Dec 13 '15 at 09:14
  • This might help, even though your original source is actually a DataTable: https://msdn.microsoft.com/en-us/library/bb669096(v=vs.90).aspx – Robert McKee Dec 13 '15 at 09:40

0 Answers0