SqlConnection myConnection = new SqlConnection("Data Source=your IP ;Initial Catalog=Your Database;User ID=sa;Password=Your password"); //SqlCommand myCommand = new SqlCommand("select * from ok", myConnection); //myConnection.Open(); //SqlDataReader dr = myCommand.ExecuteReader(); //GridView1.DataSource = dr; /**//*以上为SqlReader例 绑定 gridview 与以下dataset 比较*/ SqlDataAdapter myCommand = new SqlDataAdapter("select * from ok", myConnection); DataSet ds = new DataSet(); myCommand.Fill(ds, "ok"); DataView Source = ds.Tables["ok"].DefaultView; Source.Sort = "净重 desc"; //倒序按净重排序 GridView1.DataSource = Source ; GridView1.DataBind(); myConnection.Close();