views:

305

answers:

0

I am trying to use the selectionstart and selectionend attributes from monthcalendar to filter between two login dates in a table. When I chose one single day, this does not work correctly. If i chose the day before and the day after the day in question then it will. The time values in my DB are like this:

2/23/2010 11:17:01 AM 

Both login and logout are of that type. I have a feeling that when I use selectionstart and selection end, I just get the mm/dd/yyyy and what is in the DB is that and a time.

Here is my code:

Dim cn As OleDbConnection
    Dim cmd As OleDbCommand
    Dim str As String
    Dim dr As OleDbDataReader

    DataGridView1.Rows.Clear()

    Try
        cn = New OleDbConnection("Provider=microsoft.Jet.OLEDB.4.0;Data Source=G:\Sean\BMSBonder3_0.mdb;")
        cn.Open()
        str = "Select BonderIdentifier, UserName, Login, Logout From [Session] Where Login >= ? AND Logout <= ? AND BonderIdentifier = ?"
        cmd = New OleDbCommand(str, cn)
        cmd.Parameters.AddWithValue("Start", MonthCalendar1.SelectionStart)
        cmd.Parameters.AddWithValue("End", MonthCalendar1.SelectionEnd)
        cmd.Parameters.AddWithValue("BID", ListBox1.SelectedItem)

        dr = cmd.ExecuteReader

        While dr.Read()
            If dr.Item(0).ToString <> "" Then
                DataGridView1.Rows.Add(dr.Item(0), dr.Item(1), dr.Item(2), dr.Item(3))

            End If
        End While

        dr.Close()
        cn.Close()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try