Skip to content Skip to sidebar Skip to footer

Sqldatareader.read() Always Returning False

I have the following situation: using (SqlConnection conexao = new SqlConnection(ConnectionString)) { SqlCommand comando = new SqlCommand(query, conexao); comando.Parameter

Solution 1:

Actually, what happens is SqlDataReader.Read returns true if it is NOT the last row.

Your behavior specifies "SingleRow", so the reader aligns the reader to the first row, and returns false saying "there are no rows left after this one".

See this link Here for the documentation on this: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read.aspx

"true if there are more rows; otherwise false."

Of interest, however, their examples seem like they would ignore the very last row based on that sentence...

Post a Comment for "Sqldatareader.read() Always Returning False"