【问题标题】:i want make show only 5 records from query then pagination get next 5 till the end我想让查询中只显示 5 条记录,然后分页获取下 5 条直到最后
【发布时间】:2019-05-19 05:12:06
【问题描述】:
    connection.Open();
            OleDbCommand command = new OleDbCommand();
            command.Connection = connection;

            string querytransactions = "select TransactionID as 'الرقم المرجعي' , TransactionDate as 'تاريخ العملية' , TransactionDescription as 'وصف العملية'  , AccountID as ' الحساب' , WithdrawalAmount as ' مسحوبات' , DepositAmount as ' ايرادات' from transactions";

            command.CommandText = querytransactions;
            command.ExecuteNonQuery();
            OleDbDataAdapter da = new OleDbDataAdapter(command);
            DataTable dttransactions = new DataTable();
            da.Fill(dttransactions);
            dataGridView3.DataSource = dttransactions;
            DataSet ds = new DataSet() ;

                ds.Clear();
                da.Fill(ds, scr_val, 5);
                connection.Close();

我想在 datagridview 中只显示来自该查询的 5 条记录我正在使用 access 数据库然后分页获取下一个 5 直到最后我不需要从事务中选择前 5 个并且访问 db 没有限制查询所以我能做什么

【问题讨论】:

    标签: c# datagridview pagination visual-studio-2017 ms-access-2010


    【解决方案1】:

    您可以使用 Linq 跳过记录并从数据集的结果数据表中获取下一组数据。你会传入一个跳过计数和前端的计数。不是最有效的查询,但考虑到问题中可用的有限上下文,您可以按照以下方式做一些事情:

    ds.Tables[0].Select().Skip(5).Take(5);  // skips 5 rows, then selects five after that.
    

    【讨论】:

      猜你喜欢
      • 2022-10-01
      • 2019-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-27
      • 2013-12-31
      • 2015-11-04
      • 2017-01-02
      相关资源
      最近更新 更多