string csac = ConfigurationSettings.AppSettings["acConnectionString"];
//创建AdoHelper
AdoHelper helperac = AdoHelper.CreateHelper("oleDBDA");
PagedDataSource pds = new PagedDataSource();
pds.DataSource =helperac.ExecuteReader(csac,System.Data.CommandType.Text, "select * from roles"); //出错行
GridView2.DataSource = pds;
GridView2.DataBind();
错误是“CS0266: 无法将类型“System.Data.IDataReader”隐式转换为“System.Collections.IEnumerable”。存在一个显式转换(是否缺少强制转换?)”
应该怎么弄呢。
pds.DataSource = helperac.ExecuteDataset(csac, System.Data.CommandType.Text, "select * from roles").Tables[0].DefaultView;
这个方法的可以。datareader怎么不行呢。该怎么做呢。
//创建AdoHelper
AdoHelper helperac = AdoHelper.CreateHelper("oleDBDA");
PagedDataSource pds = new PagedDataSource();
pds.DataSource =helperac.ExecuteReader(csac,System.Data.CommandType.Text, "select * from roles"); //出错行
GridView2.DataSource = pds;
GridView2.DataBind();
错误是“CS0266: 无法将类型“System.Data.IDataReader”隐式转换为“System.Collections.IEnumerable”。存在一个显式转换(是否缺少强制转换?)”
应该怎么弄呢。
pds.DataSource = helperac.ExecuteDataset(csac, System.Data.CommandType.Text, "select * from roles").Tables[0].DefaultView;
这个方法的可以。datareader怎么不行呢。该怎么做呢。
那么直接给
string csac = ConfigurationSettings.AppSettings["acConnectionString"];
//创建AdoHelper
AdoHelper helperac = AdoHelper.CreateHelper("oleDBDA");
GridView2.DataSource = helperac.ExecuteReader(csac,System.Data.CommandType.Text, "select * from roles"); //这样是可以的
GridView2.DataBind();如果你要使用GridView自己的分页功能 那么必须是使用DataSet这样的实现了IEnumerable接口的数据类型
GridView2.DataSource = helperac.ExecuteReader(csac,System.Data.CommandType.Text, "select * from roles"); //这样是可以的
GridView2.DataBind();
这样我启动GridView2自动分页,出现“System.NotSupportedException: 数据源不支持服务器端的数据分页。“ 这个错误。