-3

I have a query : "Select IsNull(ItemBarcode,0) From Items where ItemID = 12313" If in my database, 12312 ID does not exist on my table, then what will ".NET ExecuteScalar" return to me (If I assign it to an object variable?

    private Object Result = Command.ExecuteScalar(sql);

What will be result value?

ahmet
  • 702
  • 1
  • 10
  • 29

1 Answers1

0

From memory (unchecked), if it returns a row that has, in the first cell, a database null, then it will return DBNull.Value; if it doesn't return any rows, it will return null. If there are no rows, your IsNull doesn't apply, because that is applied to each of the zero rows returned, which is to say: not at all.

But as Jon notes: just run it. If it returns a null, then that fairly conclusively answers the question "ExecuteScalar can return null?"

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900