0

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

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

“rptStudents 正在使用无效的数据源。有效的数据源必须实现 IListSource 或 IEnumerable。”

注意:从 4.1 迁移到 Enterprise library 5.0

代码:

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

结束使用

戴维德:感谢您的快速回复。

drStudents 是 IDataReader,此代码运行良好

将 dbStudents 调暗为数据库 = DatabaseFactory.CreateDatabase("eCONNECTION") 将 cmdStudents 调暗为 DbCommand = dbComments.GetStoredProcCommand("get_students")

使用 drStudents 作为 IDataReader = dbStudents.ExecuteReader(cmdStudents) With rptStudents .DataSource = drStudents .DataBind() End With End Using

4

1 回答 1

0

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

从错误中可以清楚地看出,IDataReader您收到的对象不再好,因为DataSource您应该传递一些实现IListSourceIEnumerable

于 2011-09-14T22:20:47.387 回答