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名,并且访问数据库没有限制查询,所以我该怎么办< / p>
答案 0 :(得分:0)
您可以使用Linq跳过记录,并从数据集的结果数据表中获取下一组数据。您将从前端传递跳过计数和采用计数。不是最高效的查询,但是鉴于问题中可用的上下文有限,您可以按照以下方式进行操作:
ds.Tables[0].Select().Skip(5).Take(5); // skips 5 rows, then selects five after that.