我只想绑定前三条数据,请问这样写正确么? ss.DataSource = ds.Select("top 3 ");
            ss.DataBind();

解决方案 »

  1.   

    人的想像力太可怕了。 ss.DataSource= 你连接数据库的方法("select top 3 * from 表名");
                ss.DataBind();
      

  2.   

    拜托,我的想法是取出datatable的前三条记录,你自己不看题目就回答,直接就0分啊
      

  3.   

    select top 3 * from 表名
     就这撒
      

  4.   

    你居然只想绑定前3条,那为什么不读取到datatable就读3条呢?
      

  5.   

    select(string)方法中的string好像是sql语句的where条件吧?
    例子:
    private void GetRowsByFilter()
    {
        DataTable table = DataSet1.Tables["Orders"];
        // Presuming the DataTable has a column named Date.
        string expression;
        expression = "Date > '1/1/00'";
        DataRow[] foundRows;    // Use the Select method to find all rows matching the filter.
        foundRows = table.Select(expression);    // Print column 0 of each returned row.
        for(int i = 0; i < foundRows.Length; i ++)
        {
            Console.WriteLine(foundRows[i][0]);
        }
    }
      

  6.   

    myDataColumn   =   new   DataColumn();   
    myDataColumn.DataType   =   System.Type.GetType("System.Int32");   
    myDataColumn.ColumnName   =   "ID";   
    myDataColumn.AutoIncrement = true;   
    myDataColumn.AutoIncrementSeed=0;   
    myDataColumn.AllowDBNull   =   false;   
    myDataColumn.Unique   =   true;   
    myTable.Columns.Add(myDataColumn);   
    DataRow[]   foundRow=myTable.Select("ID<3");
    或  
    select top 3 * from table 
      

  7.   

    解决了,新建一个datatable 往里面加数据,超过三条跳出,哈哈,谢谢各位了!
      

  8.   

    请教12楼,DataRow[]  foundRow=myTable.Select("ID <3");这里的ID能用么?这个columnname好像用在这里不合适吧,当然我没有测试过,谢谢12楼,还请多多指点