如何从C#中的数据库中选择下一行?

这是我尝试过的代码,但是不起作用。

con.Open();
String sql = "SELECT * from bills order by sr_no OFFSET 10 ROWS ONLY ";
cmd = new OleDbCommand(sql,con);
dr1 = cmd.ExecuteReader(CommandBehavior.CloseConnection);
dataGridView1.Rows.Clear();
while (dr1.Read() == true)
{
    dataGridView1.Rows.Add(dr1[0],dr1[3]);
}
con.Close();
shinhwa3200 回答:如何从C#中的数据库中选择下一行?

SELECT * from bills order by sr_no OFFSET number_of_rows_u_want_to_skip ROWS FETCH NEXT number_of_rows_u_want_to_take  ROWS ONLY
,

使用OFFSET和FETCH:

SELECT col1,col2,...
FROM ...
WHERE ... 
ORDER BY -- this is a MUST there must be ORDER BY statement
-- the paging comes here
OFFSET     10 ROWS       -- skip 10 rows
FETCH NEXT 10 ROWS ONLY; -- take 10 rows
本文链接:https://www.f2er.com/3013943.html

大家都在问