c# - Datatable null rows -
i trying insert values datatable database working fine until added piece of code remove null values it. nothing being added presume rows getting deleted or there wrong loop...please help. tried dbnull same effect
for (int = dt.rows.count - 1; >= 0; i--) { if (string.isnullorempty((dt.rows[i][2]).tostring())) dt.rows[i].delete(); } dt.acceptchanges();
you should use:
if(dt.rows[i][2]==system.dbnull.value)
instead of if (string.isnullorempty((dt.rows[i][2]).tostring()))
also, not adding rows in code snippet included in question.
hope may help. regards,
Comments
Post a Comment