Convert Yes/No/Null from SQL to True/False in a DataTable

Posted by Scott Chamberlain on Stack Overflow See other posts from Stack Overflow or by Scott Chamberlain
Published on 2010-03-25T15:35:39Z Indexed on 2010/03/25 15:53 UTC
Read the original article Hit count: 193

Filed under:
|
|
|

I have a Sql Database (which I have no control over the schema) that has a Column that will have the varchar value of "Yes", "No", or it will be null. For the purpose of what I am doing null will be handled as No.

I am programming in c# net 3.5 using a data table and table adapter to pull the data down. I would like to directly bind the column using a binding source to a check box I have in my program however I do not know how or where to put the logic to convert the string Yes/No/null to boolean True/False;

Reading a null from the SQL server and writing back a No on a update is acceptable behavior.

Any help is greatly appreciated.

EDIT -- This is being developed for windows.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql