Private Sub frmtourmaster1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As DataSet
Dim i As Integer
objConn = New connctionclass1
ds = New DataSet

ds = objConn.funFillTourLocation()
For i = 0 To ds.Tables(0).Rows.Count - 1
cmbindiantourcode.Items.Add(ds.Tables(0).Rows(i).Item("tour_location"))
Next
cmbindiantourcode.SelectedIndex = 0
End sub

My connection to the database is done.
I hve created a connection class & imported here & in that connection class I hve created a function named funFillTourLocation() & called here. Through this code i hve extraced a column named Tour_location from the database in the combo box.
Now i want that when I select a particular value in the combox box, the details related to the selected value in the combo box should get displayed in the data grid view from the database.

You could run separate SQL Select statements for the selected item

SELECT * FROM table WHERE Tour_location = '" & cmbindiantourcode.text & "'"

or you could download the whole table and bind to the datagrid then run a command like

ds.tables(0).Select("Tour_location = '" & cmbindiantourcode.text & "'")

Please help me. I want display the selected data from combobox in datagridview in vb.net. i've 5 combobox used in my project, but i want select the combobox value random and bind the data in datagridview control.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.