大家好,如何返回多行已被选中的记录的行号(假设我的数据表中每一条记录都有一个id号,这个ID号是按顺序排列的。)

解决方案 »

  1.   

    sel
    using (SqlConnection conn = new SqlConnection("")) 
                { 
                    conn.Open(); 
                    SqlCommand Comm = new SqlCommand("select * from Tb", conn); 
                    SqlDataReader reader = Comm.ExecuteReader(CommandBehavior.CloseConnection ); 
                  while (reader.Read()) 
                  { 
                      
                  }
                  conn.Close(); 
                } 
      

  2.   

    while (reader.Read()) 
                  { 
                      
                  } 
    循环已经有了行号,
    每循环N次的时候 就是N行的时候