Difference between DbNull.Value and DbNull.Value.ToString()

后端 未结 3 1249
无人及你
无人及你 2021-01-26 19:42

I wanted to learn which usage is true?

if(!string.IsNullOrEmpty(parentID))
   cmd.Parameters.Add(new SqlParameter(\"@ParentSesID\", parentID));
else
   cmd.Param         


        
3条回答
  •  隐瞒了意图╮
    2021-01-26 20:20

    DBNull.Value.ToString() will return empty string, so I think

    cmd.Parameters.Add(new SqlParameter("@ParentSesID", DBNull.Value));
    

    is a good approach and here the only approach

    see here:

    http://ideone.com/iGo1Jh

提交回复
热议问题