SqlConnection conn = new SqlConnection("Data Source=WWW-DCE529843C0;Initial Catalog=sanfuyibiao;Integrated Security=True");
            SqlCommand cmd = new SqlCommand();
            conn.Open();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from redianou";
            SqlDataAdapter sda = new SqlDataAdapter();
            sda.SelectCommand = cmd;
            DataSet ds = new DataSet();
            sda.Fill(ds, "redianou");
            dataGridView1.DataSource = ds.Tables[0];
            conn.Close();运行时dataGridView1不显示数据 空白的 谁能告诉下为什么? 另外 sda的fill方法不支持row_number()over(order by 。。) 怎么办?

解决方案 »

  1.   

    楼主,怎么ADO和sql 2005的语法混在一起了?如果dataview没有记录显示,说明ada的查询没有返回记录呀。C#的代码没有什么问题,看看是不是sql语句的原因吧。
      

  2.   

    dataset中有值吗?检查下 还有dg绑定有问题
      

  3.   

    你只是指定了数据源,而没有进行数据绑定,肯定是一片空白啦。  dataGridView1.DataSource = ds.Tables[0];
      dataGridView1.DataBind();
      conn.Close();另外,如果你要进行排序,在SQL语句里操作就行了。至于Fill方法能不能进行排序,还没有研究过。
      

  4.   

    你只是指定了数据源,而没有进行数据绑定,肯定是一片空白啦。  dataGridView1.DataSource = ds.Tables[0];
      dataGridView1.DataBind();
      conn.Close();另外,如果你要进行排序,在SQL语句里操作就行了。至于Fill方法能不能进行排序,还没有研究过。
      

  5.   

    你只是指定了数据源,而没有进行数据绑定,肯定是一片空白啦。
      dataGridView1.DataSource = ds.Tables[0];
      dataGridView1.DataBind();
      conn.Close();另外,如果你要进行排序,在SQL语句里操作就行了。至于Fill方法能不能进行排序,还没有研究过。
      

  6.   

    select * from redianou 有数据吗?确定你的数据库是有数据的?还有用户名是否正确,或当前默认数据库是否正确。
      

  7.   

    dataGridView1.DataSource = ds.Tables[0];
      dataGridView1.DataBind();