不要使用DataReader,改成使用DataSet就可以了:
OleDbDataAdapter da = new OleDbDataAdapter(sql, connection);
DataSet ds2 = new DataSet();
da.Fill(ds2, "News");
GridView1.DataSource = ds2;
GridView1.DataBind();
本文介绍了一种将DataReader替换为DataSet的方法来实现数据展示。通过创建OleDbDataAdapter并填充DataSet,可以更灵活地处理数据,并将其绑定到GridView进行显示。
不要使用DataReader,改成使用DataSet就可以了:
OleDbDataAdapter da = new OleDbDataAdapter(sql, connection);
DataSet ds2 = new DataSet();
da.Fill(ds2, "News");
GridView1.DataSource = ds2;
GridView1.DataBind();

被折叠的 条评论
为什么被折叠?