读出表中某个字段最大的前三条记录是这样的吗select top 3 question from fjjia order by num desc那怎么把这三个值分别付给label1,label2,label3啊???

解决方案 »

  1.   

    label1.Text = ds.Tables[0].Rows[0]["question"].ToString();
    label2.Text = ds.Tables[0].Rows[1]["question"].ToString();
    label3.Text = ds.Tables[0].Rows[2]["question"].ToString();
      

  2.   

    SqlCommand cmd =  new SqlCommand("select top 3 question from fjjia order by num desc",cn);
    dr = cmd.ExecuteReader(); //dr为DataReader
    label1.Text = dr.Rows[1]["question"];
    .........应该是这样,没有验证过...
      

  3.   

    使用DataAdapter 填充DataSet 楼上的方法可行的
      

  4.   

    kgdiwss(∮明天去要饭) 正解。
      

  5.   

    Control myControl;
    for(int i=0; i<3; i++ )
    {
       myControl1 = FindControl("Label" + (i + 1).ToString())
       if (myControl1 != null)
       {   
          ((System.Web.UI.WebControls.Label)(myControl)).Text = ds.Tables[0].Rows[i]["question"].ToString();
       }
      
    }