Quantcast
Channel: data reader + select count()
Viewing all articles
Browse latest Browse all 6

data reader + select count()

$
0
0

Pessoal, onde to errando?
To tentando recuperar a quantidade de registros que existem dentro de uma tabela X

a query esta perfeita, quando testo ela retorna o valor correto.

+ quando testo no código ele retorna o erro

"Invalid attempt to read when no data is present."

Segue abaixo o código.

SqlConnection conexao = newSqlConnection(strConn);
SqlCommand comando = newSqlCommand(query, conexao);
SqlDataReader dr = null;
conexao.Open();
dr = comando.ExecuteReader();
Response.Write(dr.GetInt64(0));
dr.Close();
conexao.Close();

 

 

 

Obrigado
Fernando


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images