预订房间(两个日期之间搜索)

时间:2017-09-10 19:47:54

标签: vb.net button

我试图搜索数据库以查找在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() 

0 个答案:

没有答案