Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/07/2011, 12:18
Avatar de jaullo
jaullo
 
Fecha de Ingreso: abril-2009
Mensajes: 994
Antigüedad: 15 años
Puntos: 30
Respuesta: sentencia count

Hola,

Puedes usar un Datareader para traer el valor.
Código ASP:
Ver original
  1. using (SqlConnection cn = new SqlConnection(connectionString))
  2. {
  3.     using (SqlCommand cm = new SqlCommand("SELECT count(estudiantes.id_estudiante) as total FROM estudiantes", cn))
  4.     {
  5.         cn.Open();
  6.         SqlDataReader myReader=new SqlDataReader();
  7.     myReader=cm.ExecuteReader();
  8.     if (myReader.Read())
  9.     {
  10.        string total= myReader["total"].ToString(); 
  11.     }
  12.     }
  13. }

Revisalo bien, ya que lo he echo a mano.

Saludos,

Jason Ulloa
Microsoft Community Contributor
__________________
http://geekswithblogs.net/jaullo/Default.aspx
Si te he ayudado regalame Karma positivo!!!