What is the difference between null and System.DBNull.Value?

后端 未结 6 605
忘了有多久
忘了有多久 2020-11-22 11:02

Is there any difference between null and System.DBNull.Value? If yes, what is it?

I noticed this behavior now -

while (rdr.Read())
{
    if (rdr[\"I         


        
6条回答
  •  温柔的废话
    2020-11-22 11:27

    DBNull.Value is what the .NET Database providers return to represent a null entry in the database. DBNull.Value is not null and comparissons to null for column values retrieved from a database row will not work, you should always compare to DBNull.Value.

    http://msdn.microsoft.com/en-us/library/system.dbnull.value.aspx

提交回复
热议问题