Take a look at the image. You will see I retrieve a boolean value from the IDataReader. But calling IdataReader..GetBoolean()
throws that error: The specified conversion is not valid.
While Convert.ToBoolean(drDatosDco.GetValue(6))
works fine.
at System.Data.SqlClient.SqlBuffer.get_Boolean()
at file.cs:line 54
The column data type in the database is bit
with value 1
.
The problem wasn't IdataReader
. The table type is a bit
but the information is coming from a stored procedure
where they cast the bit
to tinyint
.
As @Flydog57 said in the comments above
From the docs, anything but a BIT resultset column type will throw.
So the problem was the cast from the bit
to tinyint
.