Question

In essence my question is really about DBNull.Value. What is it compared to just null? It seems you cannot simply pass a 'null' to a command parameter unless it's a DBNull.Value, otherwise the database will reject it, but why?

Was it helpful?

Solution

yes when you are passing a datetime values especially you need to pass with DBNull.value. Because you are passing date time inside single quote if you place 'Null' like this it is treated as a string or varchar. In the same way if you pass DBNull.value means this value is not passed so sql will treat it as null.

Please visit this link. here they explained with example. This may help you.

http://onlydifferencefaqs.blogspot.in/2012/09/null-keyword-vs-dbnull-class-in-c.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top