Hi everyone. It's me again. I'm stuck on selecting a time range. I get a Data type mismatch error message with my current SQL statement. In the Access 2007 table my EventTime column is defined as date time with medium time format. I also tried changing it to long time format. Using Visual Basic 2008. Anyone know how to make this work?
Code:Private Function GetNumerator(ByVal TableArg As String) As Integer Dim connection As OleDb.OleDbConnection = NewConnection() Dim command As OleDb.OleDbCommand = connection.CreateCommand Dim OurAdapter As New OleDb.OleDbDataAdapter Dim OurDataset As New DataSet Dim OurDataTable As New DataTable Try command = connection.CreateCommand command.CommandText = "SELECT EventID,Location,Species,EventDate,EventTime,FilePath FROM " & TableArg & _ " Where (EventTime >= '" & #6:00:00 AM# & "'" & " AND EventTime <= " & "'" & #1:00:00 PM# & "')" & "" OurAdapter.SelectCommand = command OurAdapter.Fill(OurDataset, TableArg) OurDataTable = OurDataset.Tables(TableArg) Catch ex As Exception MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OkOnly, "Connection Error !!") End Try Return OurDataTable.Rows.Count End Function


Reply With Quote

Bookmarks