Filter EntityDataSource for DateTime field
I am using and EntityDateSource and I add where condition to filter the data at runtime and then bind the grid to the dataSource, but I am getting following e开发者_如何学Gorror:-
The argument types 'Edm.DateTime' and 'Edm.String' are incompatible for this operation.
Search condition looks like this:-
it.[MyDate]='8/13/2010 00:00:00'
Any Idea how this can be fixed ?
There is some thing left in the answer given by VinayC . The following will definately work as it worked for me.
use syntax such as it.[MyDate]= DATETIME '2010-13-8 00:00'
EntityDataSource.Where uses EnttiySQL sytanx. The date time literals need to be specified in YYYY-MM-DD HH:MM - see the documentation.
In short, use syntax such as it.[MyDate]='2010-13-8 00:00'
and you should be ok.
Private Sub EntityDataSource1_Selecting(sender As Object, e As System.Web.UI.WebControls.EntityDataSourceSelectingEventArgs) Handles EntityDataSource1.Selecting
Dim dat As String = Format(CDate(my_Date), "yyyy-MM-dd HH:mm:ss")
EntityDataSource1.Where = "it.my_field = CONVERT(DATETIME, '" & dat & "', 102)) "
End Sub
精彩评论