2 Replies - 1725 Views - Last Post: 18 October 2012 - 09:25 PM Rate Topic: -----

#1 compucrazy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 30-September 12

Write query to display information in a listbox

Posted 18 October 2012 - 08:55 PM

Hi!

I am trying to display database information in my listbox. I created a query that would read the information from the different tables and extract the information that I needed. Like if I needed to display those customers that had orders due that day it would display their name and item and ID. so what I need help with is the query to get this information then display it in the listbox. Help please!

    Dim con As New OleDbConnection
    
    Private Sub btnStockItems_Click(sender As System.Object, e As System.EventArgs) Handles btnStockItems.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 btnTodaysOrders_Click(sender As System.Object, e As System.EventArgs) Handles btnTodaysOrders.Click

    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Write query to display information in a listbox

#2 manos364   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 45
  • Joined: 09-October 12

Re: Write query to display information in a listbox

Posted 18 October 2012 - 09:11 PM

Why don't you get the information one by one and disply them to the listbox as single items. It would be easier.
Was This Post Helpful? 0
  • +
  • -

#3 compucrazy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 30-September 12

Re: Write query to display information in a listbox

Posted 18 October 2012 - 09:25 PM

View Postmanos364, on 18 October 2012 - 09:11 PM, said:

Why don't you get the information one by one and disply them to the listbox as single items. It would be easier.


Ok can you give me an example? because my query displays a value that is not right.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1