0
我想弄清楚如何基於按鈕單擊顯示訪問數據庫中的某些數據。例如,如果我點擊了「庫存」按鈕,那麼它將顯示庫存中物料缺貨的項目。我可以打開連接並顯示查詢信息,但這是一個很長的LINQ查詢,我不確定它來自哪裏。有關如何顯示數據庫信息的任何建議?即客戶信息,庫存產品等..在列表框中顯示數據庫信息
Option Strict On
Imports System.Data.OleDb
Public Class frmMicroland
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
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
End Class
只是改變了格式...這是正確的嗎? – compucrazy