Timeline for Calling stored procedure with a sqlCommand
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
S Jun 4, 2015 at 14:50 | history | edited | Malachi | CC BY-SA 3.0 |
fixed tags and title
|
S Jun 4, 2015 at 14:50 | history | suggested | Quill | CC BY-SA 3.0 |
fixed tags and title
|
Jun 4, 2015 at 14:41 | review | Suggested edits | |||
S Jun 4, 2015 at 14:50 | |||||
Mar 29, 2012 at 12:36 | comment | added | schlechtums | Actually, .NET will not translate null/nothing into a DBNull.Value. A SqlParameter with a null value will not be sent to the database at all. You can easily test this by creating a stored proc (or possibly prepared statement) with a parameter (with no default value) and try to send it in as a .NET null. You should get an exception saying stored procedure expected parameter but it was not passed in. if you have nulls that you want to send in you must explicitly set them to DBNull.Value. | |
Mar 29, 2012 at 12:16 | answer | added | Jeremy Bell | timeline score: 0 | |
Jan 3, 2012 at 20:13 | comment | added | Dr. Wily's Apprentice |
I like this answer. Would upvote if it provided just a little more specifics. Additionally, the ?? operator would not be applicable in this specific situation. Finally, ?? is the C# coalesce operator; the VB.NET equivalent would be to call the If function with only 2 arguments.
|
|
Jan 3, 2012 at 20:00 | comment | added | Dr. Wily's Apprentice |
I definitely agree with using nullable types. Just to clarify that further, the SqlParameter class should have no problem with taking a plain old .NET null / Nothing value and automatically translating that into a database null value. DBNull generally comes into play when you are reading data out of a database, rather than writing to it.
|
|
Jan 2, 2012 at 8:24 | comment | added | Nilesh Thakkar | You might want to check out Nullable Types and ?? Operator. You can significantly decrease the no of lines and improve your code. | |
Nov 11, 2011 at 11:21 | history | tweeted | twitter.com/#!/StackCodeReview/status/134953767954153472 | ||
S Nov 10, 2011 at 17:55 | history | suggested | Damith | CC BY-SA 3.0 |
formatting change
|
Nov 10, 2011 at 17:45 | review | Suggested edits | |||
S Nov 10, 2011 at 17:55 | |||||
Nov 9, 2011 at 23:04 | comment | added | SLaks | You should probably use nullable types for the inputs. | |
Nov 9, 2011 at 19:13 | answer | added | JColeson | timeline score: 3 | |
Nov 9, 2011 at 16:19 | answer | added | MattDavey | timeline score: 1 | |
Nov 9, 2011 at 15:51 | history | asked | m.edmondson | CC BY-SA 3.0 |