当前位置: 代码迷 >> C# >> sql数据库如何将它排序后显示出来
  详细解决方案

sql数据库如何将它排序后显示出来

热度:43   发布时间:2016-05-05 04:20:59.0
sql数据库怎么将它排序后显示出来
如下,将整表调出显示在dataGridView1里
string strSql = "select * from table";
using (SqlCommand cmd = new SqlCommand(strSql, conn))
                {
                    DataSet ds = new DataSet();
                    SqlDataAdapter sda = new SqlDataAdapter(cmd.CommandText, conn);
                    sda.Fill(ds);
                    dataGridView1.DataSource = ds.Tables[0].DefaultView;
                }
怎么先按某个字段(比如有一个字段叫ID,int型)排序后再将整表显示到dataGridView1里?
------解决思路----------------------
select order by IDe order by ID

------解决思路----------------------
select * from table order by id

------解决思路----------------------
select * from table order by id
------解决思路----------------------
在sql查询语句排下序就好了:
select order by IDe order by ID