Using a combobox to query the database

后端 未结 2 1865
轮回少年
轮回少年 2021-01-29 08:23

I have all the days of the week in a combobox, yet when selecting a day all the days are shown in my data grid... How can I use the one selected value from the combobox to searc

2条回答
  •  我在风中等你
    2021-01-29 09:15

    you are passing cbDay as a string, try changing this line

    Dim SqlQuery As String = "SELECT Time, Activity, Equipment FROM TimeTable WHERE Day = cbDay"
    

    to something like this

    Dim SqlQuery As String = String.Format("SELECT Time, Activity, Equipment FROM TimeTable WHERE Day = {0}", cbDay.Text)
    

提交回复
热议问题