标题:[讨论]一个可能和DataSet.Clear()有关的问题
只看楼主
迷失星际
Rank: 1
等 级:新手上路
帖 子:358
专家分:0
注 册:2004-7-9
 问题点数:0 回复次数:1 
[讨论]一个可能和DataSet.Clear()有关的问题
好久没来了 先跟大家问个好~ 以下是部分问题代码
//dp.Fill(ds,"table"); //Total = ds.Tables[0].Rows.Count; Total = 20; ds.Clear(); if(Current<=Total/Size&&Current>0) { dp.Fill(ds,(Current-1)*Size,Size,"table 1"); } else { dp.Fill(ds,0,Size,"table 1"); }
注意被注释掉的部分 若是去掉注释再删除Total = 20的话;ds.Clear()后再 dp.Fill(ds)就没用 一个数据都显示不出来 不知道是哪里有问题 讨论下嘛
搜索更多相关主题的帖子: Clear DataSet 
2005-09-04 20:20
迷失星际
Rank: 1
等 级:新手上路
帖 子:358
专家分:0
注 册:2004-7-9
得分:0 

[CODE]<%@ Page Language="C#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">

void Page_Load(Object sender,EventArgs e) { int Total,Current,Size; Size = 5; if(!Page.IsPostBack) { Current = 1; } else { Current = 1; //Current = Convert.ToInt32(Request.QueryString["PageNumber"]); } OleDbCommand myCommand; OleDbConnection myConnection = new OleDbConnection(); string dbname; dbname = Server.MapPath("a.mdb"); myConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname; myConnection.Open(); OleDbDataAdapter dp = new OleDbDataAdapter("SELECT * FROM a",myConnection); DataSet ds = new DataSet(); //dp.Fill(ds,"table"); //Total = ds.Tables[0].Rows.Count; Total = 20; ds.Clear(); if(Current<=Total/Size&&Current>0) { dp.Fill(ds,(Current-1)*Size,Size,"table 1"); } else { dp.Fill(ds,0,Size,"table 1"); } MyDataGrid.DataSource = ds; MyDataGrid.DataBind(); Label1.Text = Convert.ToString(Current)+" "+Convert.ToString(Size); }

</script> <html> <head> </head> <body> <form runat="server"> <table width="70%" align="center" border="1"> <asp:Repeater id="MyDataGrid" runat="server"> <ItemTemplate> <tr> <td> <%# DataBinder.Eval(Container.DataItem,"col1")%> </td> <td> <%# DataBinder.Eval(Container.DataItem,"col2")%> </td> <td> <%# DataBinder.Eval(Container.DataItem,"col3") %> </td> </tr> </ItemTemplate> </asp:Repeater> <tr><td colspan="3"> <asp:Label ID = "Label1" runat = "server"/> </td></tr> </table> </form> </body> </html> [/CODE]这里是全部代码


2005-09-04 20:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-26702-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.065516 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved