【发布时间】:2015-03-14 14:56:40
【问题描述】:
我正在使用 VB 将 Access 数据库连接到我的程序,并且我有两个组合,我希望第二个组合数据源取决于第一个组合选定项,这是我到目前为止所做的代码:
Try
Dim dbcon As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\inventorysys.accdb;Persist Security Info=False;")
dbcon.Open()
Dim sqlquery As String = ("SELECT DISTINCT Brand FROM inventory WHERE Category = ' " & catogerycombotxt.SelectedItem & " ' ")
Dim comm As New OleDb.OleDbCommand(sqlquery, dbcon)
Dim rs As OleDb.OleDbDataReader = comm.ExecuteReader
Dim dt As DataTable = New DataTable
dt.Load(rs)
' as an example set the ValueMember and DisplayMember'
' to two columns of the returned table'
brandcombotxt.DataSource = dt
brandcombotxt.ValueMember = "Brand"
brandcombotxt.DisplayMember = "Brand"
dbcon.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
它没有错误但没有结果,希望你能帮助我
【问题讨论】: