Jan 12 2006

Bit Column in Microsoft SQL Server

Category: ASP.NET 1.x | ASP.NET 2.0 - GeneralBil@l @ 07:57

In my work today, I faced a very weird thingy, here it is:

I was retreiving a bit column from the table whose default value is set to 0, and then using an SqlDataReader, and the weird thing is that I used:

1- (bool)reader[col]
2- Convert.ToBoolean(reader[col]])
3- reader.GetInt32(col)

Nothing worked but:

Convert.ToBoolean( Convert.ToByte( reader[col] ) )

Can anyone explain why that happened? I beleive, option #1 should work pretty simple.


Tags: ,

Comments are closed