|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datatable.selectI am using Access 2003 and VS 2005 Professional I retrieve data from an access DB into a datatable then need to select rows that match a short time value I can retrieve by time from Access OK e.g sql = "Select [Details], [mytime], [endtime], [mydate], [member] from [appointments] where [instructornumber] = " & instructornumber & " and [mydate] = #" & Format(mydate, "MMM d, yyyy") & "# and [mytime] = #" & Format(dr("Time"), "t") & "# order by mydate" dtweek = getdata(sql) but I can't get the datatable.select to return rows with the same matching criteria e.g drrows = dtweek.Select("mydate = #" & Format(mydate, "MMM d, yyyy") & "# AND mytime = #" & Format(dr("Time"), "t") & "#") In the sql line 'mydate' is an access 2003 DateTime field with a format of Medium Time In the select line dr("Time") is a datacolumn from a datatable of type System.DateTime The following works OK... drrows = dtweek.Select("mydate = #" & Format(mydate, "MMM d, yyyy") & "#") It is the time field that is the problem Any ideas please Regards Steve Hi steve,
The datatable engine is not so powerful as the Jet is. It cannot parse all the formats of DateTime that Jet does. When filtering a date from DataTable, I suggest you try to use #mm/dd/yyyy# like "Birthdate < #1/31/82#". Also, it is not safe to concatenate strings to build the SQL statement. Hackers can use injection attack with this. You can use the Parameters to get over this. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
Displaying info in status bar of main form
Why won't my DataTable.Update? how to persist color settings in my app? VB2005 - Bound Date TextBox Issues DirectCast - Why is this not working? Inserting an image file in a datagrid view column- how AutoIdent Windows Service and App.Config problem Conversion Questions about DataGrid |
|||||||||||||||||||||||