Vb.net 实体数据源中的参数所在的日期时间

Vb.net 实体数据源中的参数所在的日期时间,vb.net,entity-framework,Vb.net,Entity Framework,我想在一个实体框架查询中进行筛选,该查询记录了编写日期,为此我编写了此代码,但我遇到了查找错误 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 = str

我想在一个
实体框架查询
中进行筛选,该查询记录了编写日期,为此我编写了此代码,但我遇到了查找错误

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\u note.DataBind()
code时,我得到了以下信息:


查询语法无效。短期'00',第6行,第27列。

您错过了日期周围的引号:

试试看:
stringa\u where=“it.data\u nota=”&data\u 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
EntityDataSource\u note.Where=“it.data\u nota=@param1”
//需要时的备选方案:
//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

Hi,我尝试了您的解决方案,也尝试了stringa_where=“it.data\u nota=”&Convert.ToDateTime(data_temp)&“”,但我得到的参数类型“Edm.DateTime”和“Edm.String”与此操作不兼容。好的,我尝试了方案B,数据绑定正常,但我得到了以下错误:“实体类型‘antiriciclaggio.note_pratica’的元数据中不存在名为‘it.data_nota’的属性”“。但是在antiriciclaggio.note_pratica中,我有这个属性。抛出的错误在哪里?您可以发布ListView的客户端代码吗?如果您有绑定到属性的字段,请确保删除别名,即:
我解决了它,抱歉!在我的参数中,我写了data\u ntoa而不是data\u nota。顺便提一下,我还有另一个问题:在addWhereParameter中,我可以添加一个子句作为:“parameter