如何使用Visual Studio在SQL中选择Next 10行 [英] How to select Next 10 rows in SQL using visual Studio

查看:101
本文介绍了如何使用Visual Studio在SQL中选择Next 10行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010窗体和SQL Server 2008.我想在gridview上选择10行。如果我单击下一个按钮,则必须显示接下来的10行。



我的代码是:

  public   void  loading1()
{
cn.Open();
da1 = new SqlDataAdapter( SELECT TOP 10 * FROM Phone_Number;,cn);
ds1 = new DataSet();
da1.Fill(ds1);
if (ds1.Tables [ 0 ]。Rows.Count > 0
{
// comboBox1.Items.Clear();
for int i = 0 ; i < ds1.Tables [ 0 ]。Rows.Count; i ++)
{
dataGridView1.DataSource = ds1.Tables [ 0 ];
}
}
cn.Close();

}



但是我不知道如何选择接下来的10行..帮帮我..

解决方案

查看以前解决方案的相同要求:

在sql server中选择第二行100行 - 解决方案3 [ ^ ]

在sql server中选择第二行100行 - 解决方案1 ​​ [ ^ ]



祝您好运,

Edo


您可以通过acc / dec选择数据库订单中的所有数据



点击第一次你只加载10条记录


第二次点击你清除drid视图

并加载下10条记录



抱歉,如果我错了

I am using Visual Studio 2010 windows form and SQL Server 2008. I want select 10 rows on the gridview. If i click next button the next 10 rows have to show.

My codes are:

public void loading1()
        {
            cn.Open();
            da1 = new SqlDataAdapter("SELECT TOP 10 * FROM Phone_Number;", cn);
            ds1 = new DataSet();
            da1.Fill(ds1);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                //comboBox1.Items.Clear();
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    dataGridView1.DataSource = ds1.Tables[0];
                }
            }
            cn.Close();

        }


But i don't know how to select next 10 rows.. Help me..

解决方案

See previous solution to the same requirement:
select second 100 rows in sql server - Solution 3[^]
select second 100 rows in sql server - Solution 1[^]

Good luck,
Edo


u select all data from data base order by acc/dec

on 1st click u load only 10 records

on second click u clear the drid view
and load next 10 records

sorry if i am wrong


这篇关于如何使用Visual Studio在SQL中选择Next 10行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆