Hi VB Legends,
I've been struggling with a program to access a database with three tables and present some of the information in a couple of listboxes.
I'm afraid my brains turned to mush and I can't find anything that seems to help. Any assistance very welcome.
When I push the btnOutOfStock, The heading doesn't print and I get a bunch of System.DataRow.Views in the listbox. Obviously grabbed the wrong end of the box somewhere!
The relevant code is below:
Many thanks!
I've been struggling with a program to access a database with three tables and present some of the information in a couple of listboxes.
I'm afraid my brains turned to mush and I can't find anything that seems to help. Any assistance very welcome.
When I push the btnOutOfStock, The heading doesn't print and I get a bunch of System.DataRow.Views in the listbox. Obviously grabbed the wrong end of the box somewhere!
The relevant code is below:
VB.NET:
Private Sub btnOutOfStock_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnOutOfStock.Click
Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
Dim dataAdapter2 As New OleDb.OleDbDataAdapter(sqlStr2, connStr)
Dim qtyInStock As Double
Dim fmtStr As String = "{0, -40}"
lstStock.Items.Add(String.Format(fmtStr, "Items that are currently
out of stock."))
lstStock.Items.Add(String.Format(fmtStr, "--------------------------------------"))
dataAdapter.Fill(dt)
dataAdapter2.Fill(dt2)
dataAdapter.Dispose()
lstStock.DataSource = dt
lstStock.DisplayMember = "Name"
For i = 0 To dt2.Rows.Count - 1
qtyInStock = dt2.Rows(i)("quantity")
For j = 0 To dt.Rows.Count - 1
If dt2.Rows(i)("itemID") = dt.Rows(j)("itemID") Then
qtyInStock -= dt.Rows(i)("quantity")
End If
Next
If qtyInStock <= 0 Then
lstStock.DisplayMember = dt2.Rows(i)("description")
End If
Next
End Sub
Last edited by a moderator: