|
-
May 6th, 2014, 08:51 PM
#1
Thread Starter
Junior Member
Problem with VB Code
The database Microland.accdb is maintained by the Microland Computer Warehouse, a mail-order computer-supply company. The tables below show data in the three tables in the database. The table Customers identifies each customer by an ID number and gives, in addition to the name and address, the total amount of purchases during the current year prior to today. The table Inventory identifies each product in stock by an ID number and gives, in addition to its description and price (per unit), the quantity in stock at the beginning of the day. The table Orders gives the orders received today. Assume that it is now the end of the day. Write a Visual Basic program that uses the three tables to do the following two tasks:
1. Display in a listbox the items that are out of stock and those that must be reordered to satisfy today’s orders.
2. Display in a listbox bills for all customers who ordered during the day. Each bill should show the customer’s name, address, items ordered (with costs), and total cost of the order.
My problem however is with the 'MICROLANDDataSet.Orders and MICROLANDDataSet.Inventory'. I keep getting an error saying, 'reference to a non-shared member requires an object reference'. Any ideas on how to fix this?
Code:
Imports System.Data.OleDb
Imports MicroLand.MICROLANDDataSet
Public Class MicroLand
Dim con As New OleDbConnection
Dim dataset As New MICROLANDDataSet
Private Sub btnOut_Click(sender As System.Object, e As System.EventArgs) Handles btnOut.Click
Dim query1 = From anyOrder In MICROLANDDataSet.Orders
Join itsStockItem In MICROLANDDataSet.Inventory
On anyOrder.itemID Equals itsStockItem.itemID
Let orderQuantity = anyOrder.quantity
Select itsStockItem.quantity, itsStockItem.description, anyOrder.itemID
Order By quantity, itemID
''Test connection to make sure it opens first
Try
con = New OleDb.OleDbConnection("provider= microsoft.ace.oledb.12.0;Data Source = C:\Users\HPG62-220US\Documents\Visual Studio 2010\Projects\Asignment 9\Asignment 9\bin\Debug\MICROLAND.accdb; Persist Security Info=False;")
Try
Call con.Open()
Catch ex As Exception
MessageBox.Show("Could not connect")
End Try
If con.State = ConnectionState.Open Then
MessageBox.Show("Connection is open")
End If
Catch ex As Exception
End Try
Dim ReturnedData As DataTable
ReturnedData = query1.Copy()
lstOutput.Items.Add("Here are the items that are out of")
lstOutput.Items.Add("inventory or must be reordered.")
lstOutput.Items.Add("")
lstOutput.Items.Add("The numbers shown give the")
lstOutput.Items.Add("minimum reorder quantity required.")
lstOutput.Items.Add("")
lstOutput.Items.Add(query1)
con.Close()
End Sub
Private Sub btnBills_Click(sender As System.Object, e As System.EventArgs) Handles btnBills.Click
End Sub
End Class
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|