我试图搜索数据库以查找在datetimepickers中选择的日期(也包括中间日期),然后从组合框中删除项目。但是,没有错误,只有选中后数据仍然在组合框中。
Dim date1 As DateTime = dtpDateIn.Value()
Dim date2 As DateTime = dtpDateOut.Value()
Dim da As OleDbDataAdapter = New OleDbDataAdapter
Dim BookingFound As String = False
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
MyConn.Open()
str1 = ("Select * from BookingInformation where [Date In] >= '" & date1 & "' AND [Date Out] <= '" & date2 & "'")
Dim cmd1 As OleDbCommand = New OleDbCommand(str1, MyConn)
dr = cmd1.ExecuteReader
While dr.Read()
BookingFound = True
strDateOut = dr("Date Out").ToString
strDateIn = dr("Date In").ToString
strRoomNumber = dr("Room Number").ToString
CmbRooms.Items.Remove(strRoomNumber)
End While
MyConn.Close()