SQL DataReader how to show null-values from query

Posted by cc0 on Stack Overflow See other posts from Stack Overflow or by cc0
Published on 2010-05-05T12:34:07Z Indexed on 2010/05/05 12:38 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

I have a DataReader and a StringBuilder (C#.NET) used in the following way;

                while (reader.Read())
                {
                    sb.AppendFormat("{0},{1},{2},",reader["Col1"], reader["Col2"], reader["Col3"]);
                }

Which works great for my use, but when a row is null I need it to return "null", instead of just "". What would be a good way of accomplishing that?

Suggestions are very appreciated

© Stack Overflow or respective owner

Related posts about sql

Related posts about datareader