i'm working with a travels project i have two tables(vehicle_entry and booking).. when i try to book on some particular date only available vehicle names should be shown in the combo box...
it shold show all the names from vehicle_entry table except that vehicle is registered in booking table on that date.

i tried combo box add item and then remove item but i can't and i used if...else technique after that i searched but still i didnt' get soultion

Here is an example of loading a combobox

Dim con As New SqlConnection("Server=.\SQLEXPRESS;Database=PUBS;Trusted_Connection=yes;")
Dim cmd As New SqlCommand("", con)

cmd.CommandText = "SELECT au_lname FROM authors WHERE city = 'Oakland'"


Dim rdr As SqlDataReader = cmd.ExecuteReader


Do While rdr.Read()


Just modify the SELECT statement to select the appropriate values from your table.

You need to join the vehicle_entry and booking tables.
Hint: Inner vs. Outer Join
I assume your UI has a calendar(theDate) & the ComboBox (AvailableVehicles).
So the available vehicles (vehicle_entry) for a particular day (where booking.Date == theDate) will NOT have a related booking row.

AvalableVehicles = new ObservableCollection<Vehicle>();
ComboBox1.DataSource = AvalableVehicles;

Change Date:
AvalableVehicles = Add all vehicles returned by GetAvalableVehicles(theDate);

Vehicle[] GetAvalableVehicles(DateTime theDate) // query database

Do NOT manipulate the combobox as previously suggested.
ComboBox1.Items BAD

This article has been dead for over six months. Start a new discussion instead.