我试图弄清楚如何根据按钮单击显示访问数据库中的某些数据。例如,如果我单击“库存”按钮,它将显示数据库中缺货的项目。我能够打开连接并显示查询信息,但这是一个很长的 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