DateTime其中实体数据源中的参数

时间:2014-03-28 11:14:05

标签: vb.net entity-framework

我想过滤一个注明写作日期的Entity Framework Query,为此我编写了这段代码,但我遇到了发现错误;

Dim stringa_where as String
Dim data_temp As String = giorno & "/" & mese & "/" & anno & " 00:00:00"
stringa_where = "it.data_nota=" & data_temp
EntityDataSource_note.Where = stringa_where
EntityDataSource_note.DataBind()
ListView_note.DataSource = EntityDataSource_note
ListView_note.DataBind()
ListView_note.Visible = True

当我到达ListView_note.DataBind()代码时 - 我明白了:

查询语法无效。近期' 00',第6行,第27栏。

1 个答案:

答案 0 :(得分:1)

您错过了约会日期的报价:

尝试:stringa_where = "it.data_nota='" & data_temp & "'"

好的 - 计划B.尝试:

EntityDataSource_note.Where = "it.data_nota = @param1"
// alternative when < is required:
// EntityDataSource_note.Where = "it.data_nota < @param1"
EntityDataSource_note.WhereParameters.Add("param1", TypeCode.DateTime, new DateTime(anno, mese, giorno).ToString())
EntityDataSource_note.DataBind()
ListView_note.DataSource = EntityDataSource_note
ListView_note.DataBind()
ListView_note.Visible = True