How to retrieve a value from a Date / Time field


I get an error at adapter.Fill(dtFuelpriceinfo):

"No value given for required parameters".

TimeOut is a Date/Time field. But if I replace it with any field with a string data type, it works.

I just don't know how to retrieve its value because it's a Date/Time field.

Public Shared Function Check8HourTimeOut(ByVal EmpID As String) As String
    Dim x As String
    Dim dtfuelpriceinfo As New DataTable

    If Not DBConnection.State = ConnectionState.Open Then


    End If

    Dim adapter As New OleDbDataAdapter("SELECT TimeOut FROM EmployeeAttendance where " & _
                                          "EmployeeID='" & EmpID & "' order by WorkingDate desc", DBConnection)

    x = dtfuelpriceinfo.Rows(0).Item(0)

    Return x       

End Function

What if you change from "DataTable" type to "DataSet", like so:

DIM dtfuelpriceinfo as Dataset

and see if you still get the error upon your attempt to fill the DataSet. If so, then I'd double-check your SQL to be sure it is actually pulling some records.

Another idea: Maybe EmpID is an integer? Your SQL assumes it is a string. You probably know that.

Oh and (the following change may not be necessary because "tables(0)" is probably optional/assumed, but just in case:

x = dtfuelpriceinfo.Tables(0).Rows(0).Item(0)

Apology if I'm way off!