troubleshooting Question

VB 2010 LINQ to Untyped Dataset (3)

Avatar of skdan
skdanFlag for Slovakia asked on
Visual Basic.NET
9 Comments1 Solution598 ViewsLast Modified:
Hi experts,

My situation:
- Visual Studio Professional 2010
- .NET Framework 4

I try to use code from Microsoft site:

My working code:

Option Explicit On

Imports System.Data.OleDb

Imports System
Imports System.Linq
Imports System.Linq.Expressions
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Globalization

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim conn1 As OleDbConnection

        Dim ds As DataSet = New DataSet
        Dim sqlcmd As OleDbCommand
        Dim da As OleDbDataAdapter = New OleDbDataAdapter


            conn1 = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=f:\Demo\Access\myDB1.accdb")

            sqlcmd = New OleDbCommand("SELECT * FROM SalesOrderHeader ", conn1)

            da.SelectCommand = sqlcmd
            da.Fill(ds, "SalesOrderHeader")

            sqlcmd = New OleDbCommand("SELECT * FROM SalesOrderDetail", conn1)

            da.SelectCommand = sqlcmd
            da.Fill(ds, "SalesOrderDetail")

            Dim orders As DataTable = ds.Tables("SalesOrderHeader")
            Dim details As DataTable = ds.Tables("SalesOrderDetail")

            Dim query = _
                From order In orders.AsEnumerable() _
                Join detail In details.AsEnumerable() _
                On order.Field(Of Object)("SalesOrderID") Equals _
                        detail.Field(Of Object)("SalesOrderID") _
                Where order.Field(Of Boolean)("OnlineOrderFlag") = True And _
                        order.Field(Of DateTime)("OrderDate").Month = 8 _
                Select order

            Dim ord

            For Each ord In query
                Console.WriteLine(ord("SalesOrderID") & vbTab & _
                    ord("OrderDate") & vbTab & _

        Catch ex As Exception

        End Try
    End Sub
End Class

I would like to have in "Select" command also all columns from table "details", some thing like:

Select order, detail

but I get error.

Ioannis Paraskevopoulos

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros