【问题标题】:Error when binding repeater with IDataReader after converting asp.net 3.5 to 4.0将 asp.net 3.5 转换为 4.0 后将转发器与 IDataReader 绑定时出错
【发布时间】:2011-09-15 07:31:35
【问题描述】:

我正在尝试将 asp.net 3.5 应用程序迁移到 asp.net 4.0 版本。

asp.net 3.5 运行正常,迁移到 asp.net 4.0 后出现以下错误

"rptStudents 使用了一个无效的数据源。一个有效的数据 source 必须实现 IListSource 或 IEnumerable。”

注意:从 4.1 迁移到 Enterprise library 5.0

代码:

Using drStudents As IDataReader = dbStudents.ExecuteReader(cmdStudents)
                With rptStudents
                    .DataSource = drStudents
                    .DataBind()
                End With

结束使用

Davide:感谢您的快速回复。

drStudents 是一个 IDataReader,这段代码运行良好

Dim dbStudents As Database = DatabaseFactory.CreateDatabase("eCONNECTION") Dim cmdStudents As DbCommand = dbComments.GetStoredProcCommand("get_students")

使用 drStudents 作为 IDataReader = dbStudents.ExecuteReader(cmdStudents) 与 rptStudents .DataSource = drStudents .DataBind() 结束于 结束使用

【问题讨论】:

    标签: asp.net idatareader


    【解决方案1】:

    drStudents 变量的实际对象类型是什么?

    从错误中很明显IDataReader 或您收到的对象不再像DataSource 那样好,您应该传递实现IListSource 或IEnumerable 的东西

    【讨论】:

    • 戴维德:感谢您的快速回复。 drStudents 是一个 IDataReader,此代码在带有企业库 4.1 的 aps.net 3.5 中工作,当我将应用程序迁移到带有企业库 5.0 的 asp.net 4.0 时出现错误。 Dim dbStudents As Database = DatabaseFactory.CreateDatabase("eCONNECTION") Dim cmdStudents As DbCommand = dbComments.GetStoredProcCommand("get_students") Using drStudents As IDataReader = dbStudents.ExecuteReader(cmdStudents) With rptStudents .DataSource = drStudents .DataBind() End With
    猜你喜欢
    • 1970-01-01
    • 2012-10-08
    • 2013-03-06
    • 1970-01-01
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    • 2011-05-13
    • 2012-05-23
    相关资源
    最近更新 更多