0
當我想選擇一個酒店名稱我想每家酒店的名字與房號分配給它具有組合框顯示system.data.datarowview vb.NET
sqlCmd1 = "Select ROID from Room"
ad = New OleDb.OleDbDataAdapter(sqlCmd1, cnn)
ds = New DataSet
ad.Fill(ds, "Room")
For Each row As DataRow In ds.Tables(0).Rows
roomCB.Items.Add(row.Item(0))
Next
這是爲酒店組合框
Private Sub hotelCB_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles hotelCB.SelectedIndexChanged
If (hotelCB.SelectedIndex = 0) Then
sqlCmd1 = "Select ROID from Room"
ad = New OleDb.OleDbDataAdapter(sqlCmd1, cnn)
ds = New DataSet
ad.Fill(ds, "Room ID")
roomCB.DataSource = ds.Tables(0).DefaultView
ElseIf (hotelCB.SelectedIndex = 1) Then
sqlCmd1 = "Select ROID from Room where HotelID=" +
hotelCB.SelectedIndex.ToString()
ad = New OleDb.OleDbDataAdapter(sqlCmd1, cnn)
ds = New DataSet
ad.Fill(ds, "Room ID")
roomCB.DataSource = ds.Tables(0).DefaultView
End If
End Sub
你能更具體嗎?什麼是實際問題或者你得到什麼錯誤? – Hexaholic
很酷。有什麼問題? – Banana
@Banana:問題在標題中說明:combobox顯示'System.data.datarowview'而不是ROID。 –