using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page 
{    protected void btnname_Click(object sender, EventArgs e)
    {        OleDbConnection dbconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\inetpub\wwwroot\WebSite\pei.mdb");
        dbconn.Open();
        OleDbCommand cmd=new OleDbCommand("select * from login",dbconn);         OleDbDataReader reader = cmd.ExecuteReader();                        //表里有id 和 name 2个子段
            Response.Write(reader["id"] + "&nbsp;&nbsp"+reader["name"]+"<br>");
            reader.Read();
           
  
    }
}我怎么样点击btnname按钮后可以让纪录向下移动一条,谢谢!马上给分!

解决方案 »

  1.   

    用session记录次数,点一下,让他加一
    OleDbCommand cmd=new OleDbCommand("select * from login ",dbconn); 
    select * from login where id=session[]的值。
      

  2.   

    把DataReader给写在方法的外面(写成全局量),我们在点击时,只需要先得到上次的索引号,再加1就可以得到下一条的索引号了
      

  3.   

    在按钮的事件中reader.Read();
    reader.Read()功能使reader前进到下一条记录
      

  4.   

    zerocoin(木目木),请问怎么获得上次的索引号,谢谢!
      

  5.   

    定义个ViewState["currentRecCount"] = DataSet.Tables[0].Rows.count;  --记录数
    然后再定义的个ViewState["currentRec"] = 0;--当前浏览index
    这两个在 page_load事件里面的if(!IsPostBack){这里加}
    每次点击按钮就
    int cRec = Convert.ToInt32(ViewState["currentRec"].ToString().Trim());
    ViewState["currentRec"] = cRec+1;
      

  6.   

    jimu8130(IBMT43)
    谢谢,不过数据库中怎么样操作呢,我每点击一次按钮,数据就会next一条!
      

  7.   

    你要实现怎么样的效果了?是否是你把这些数据绑定在相对应的textbox了?
    上面的数据源是dataset!如果是的话,那么你就可以在点击按钮事件里面这样写了
    int cRec = Convert.ToInt32(ViewState["currentRec"].ToString().Trim());
    ViewState["currentRec"] = cRec+1;
    myds = OleDbConnection dbconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\inetpub\wwwroot\WebSite\pei.mdb");
            dbconn.Open();
            OleDbCommand cmd=new OleDbCommand("select * from login",dbconn);        DataSet myds= cmd.ExecuteDataSet();
    TextBox1.Text = myds.Tabels[0].Rows[cRec+1]["ID"].ToString();
    ....
      

  8.   

    你的思路不对 你用了WinForm的思想 两个不是一回事,用SQL语句吧
    每次调用一次查询
    Select top 1 * from login where id>currentId order by id