Insert null datetime


















Copy Code. Posted Mar pm rajesh Add a Solution. Saral S Stalin Mar am. Top Rated Most Recent. Accept Solution Reject Solution. Allow null values in the table and do not pass any parameter while inserting values in this column.

Posted Mar pm Mukund Thakker. Shahin Khorshidnia Mar am. Mukund Thakker Mar am. Thank you. This works as long at the default value hasn't been changed to something other than null. Value pretty much works every time — Linky.

Linky Ahh. I've never personally had issue with it but that's interesting to know and keep in mind. If you add a Parameter with value null, the parameter won't be part of the executed sql any more and if your stored procedure requires this parameter, execution will fail. SWeko's answer also mentions that. If you're building statements like "Insert into X col values col " it doesn't make a difference as far as I know. Try using: if string. This is basically what he was using, and what was throwing the error.

Issue is because it is sending SqlDateTime. Null , both on his and yours, when he should be sending DBNull. Try this logic if DBNull. Value is not worked.. Shanmuga priya Shanmuga priya 1 1 1 silver badge 3 3 bronze badges. You can use this. There i no shortcut!! Fuat Fuat 9 9 silver badges 13 13 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Why not?

It's a business rule, a blank value will set the column to just made the edit — NealR. A business rule? For an implementation detail??? If you need to set the value of the field to null which you state you need to , what's the issue with setting the variable to null? Where does the business come into it? It's a datetime field. You can't set a variable value to be 'NULL' or anything other than datetime or it won't work.

How are you trying to set it? Show 1 more comment. Active Oldest Votes. Improve this answer. Viewed k times. I mean, if there is no value inserted, the default value should be null, empty, etc.

Improve this question. David Refoua 3, 1 1 gold badge 28 28 silver badges 51 51 bronze badges. Ozi Oz Ozi Oz 1 1 gold badge 4 4 silver badges 12 12 bronze badges. Add a comment. Active Oldest Votes. DateTimeColumn DateTime, Improve this answer. Tharif Mahmoud Gamal Mahmoud Gamal The issue is, that if the input is empty, then it shouldn't put ' etc' but NULL, and i shouldn't have to put all those conditions then — Ozi Oz.



0コメント

  • 1000 / 1000