如下,将整表调出显示在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