Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27254

joining two queries

$
0
0
So I have two queries from 3 tables in a database:
Dim custorders = From cust In _MICROLAND_1_DataSet1.Customers
Join orders In _MICROLAND_1_DataSet.Orders
On cust.custID Equals orders.custID
Select cust.name & " " & cust.street & " " & cust.city

Dim invtotal = From inv In _MICROLAND_1_DataSet2.Inventory
Join ord In _MICROLAND_1_DataSet.Orders
On inv.itemID Equals ord.itemID
Where (Total = (inv.price * ord.quantity))
Select ord.quantity & " " & inv.description & " " & FormatCurrency(Total)

I want to join the two information and then list it in the list box as
custname
custstreet
custcity

order quantity, item description, total
etc
Total amount: blank

I've tried:
Dim bill = custorders.Union(invtotal)
lstBox.DataSource = bill.ToList
lstBox.SelectedItem = Nothing
The customers who bought items show up once (which is what I want) but all on one line and the second query doesn't show up

If I just do the first query, the customers show up but they show up the total number of times they bought something and the second query doesn't work by itself.

How would I join the two queries and get them displayed correctly? If you could explain you're reasoning behind your answer so I learn from it, that would be much appreciated.

Viewing all articles
Browse latest Browse all 27254

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>