Vidhura

What is the difference between setting

datagridviewtextboxcolumn.DefaultCellStyle.NullValue = null and

datagridviewtextboxcolumn..DefaultCellStyle.NullValue = System.DBNull.Value



Re: Windows Forms Data Controls and Databinding Setting null value to datagridviewtextboxcolumn.DefaultCellStyle.NullValue

Martin Xie - MSFT

You can get a little of inspiration from the following code sample.

public string CustomerName(int custId)
{

SqlCommand cmd = new SqlCommand(string.Format("SELECT Name FROM Customers WHERE idCust={0}",custId), sqlConnectionToSchaakBondDB);
object result = cmd.ExecuteScalar();

if (result == null)
return "Customer not found"
;
if
(result == System.DBNull.Value)
return "Customer found but name is null"
;
return (string) result;

}

Please check System.DBNull.Value != null for detail.