.net - How to find if a value is NULL in SQL Server using c# -


i know values null in datatable in c# returned executedatatable of sqlhelper class.

string select = "select * testtable"; string val="";  datatable  dt=dbcon.executedatatable(select); foreach (datarow dr in dt.rows) {    foreach (datacolumn  dc in dt.columns )    {        if(dr[dc].equals (null))        {           val ="null";        }         else          {           val = dr[dc].tostring();        }    } } 

but unfortunately didn't find way it. please let me know if there way. thank in advance.

as david m's method, can use datarow.isnull:

if (dr.isnull(dc)) 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -