Author |
Topic |
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-08-04 : 11:10:08
|
Can datetime datatype accpet NULL?I set it as Nullable but i got error if i pass null parameter. |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-04 : 11:12:43
|
yes it can be nullable in sql server.how are you setting it to null?_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-04 : 11:13:02
|
quote: Originally posted by kwikwisi Can datetime datatype accpet NULL?I set it as Nullable but i got error if i pass null parameter.
1 Yes2 Show us the codeMadhivananFailing to plan is Planning to fail |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-04 : 11:13:31
|
MadhivananFailing to plan is Planning to fail |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-08-04 : 11:16:13
|
@date datetimeinsert into testtable(sdate,...)values(@date,...)If User set as blank at front-end ,i get error like "Input string cannot reconized as valid datetime"quote: Originally posted by madhivanan
MadhivananFailing to plan is Planning to fail
|
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-08-04 : 11:19:15
|
What do you mean by blank?How does the user set the blank value?MadhivananFailing to plan is Planning to fail |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-08-04 : 11:21:04
|
There's a txtbox for user input.I mean if user didn't put anything,get error.quote: Originally posted by madhivanan What do you mean by blank?How does the user set the blank value?MadhivananFailing to plan is Planning to fail
|
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-04 : 11:29:10
|
then you have to do in pseudo codeif (txtDateInput.Test == "") @myDateParamValue = DbNull.Value;DbNull.Value is a special null value that you set to SqlParameters_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-08-04 : 11:36:44
|
u mean like?if txtdate.text<>"" thenparamdate.value=dbnull.valueelseparamdate.value=txtdate.textend ifquote: Originally posted by spirit1 then you have to do in pseudo codeif (txtDateInput.Test == "") @myDateParamValue = DbNull.Value;DbNull.Value is a special null value that you set to SqlParameters_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
|
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-08-04 : 11:48:11
|
if txtdate.text = "" then -- my guess is that you want to put null if the text box is emptyparamdate.value=dbnull.valueelseparamdate.value=txtdate.textend if_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
kwikwisi
Constraint Violating Yak Guru
283 Posts |
Posted - 2008-08-04 : 11:55:40
|
Thank u for your guide  quote: Originally posted by spirit1 if txtdate.text = "" then -- my guess is that you want to put null if the text box is emptyparamdate.value=dbnull.valueelseparamdate.value=txtdate.textend if_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
|
 |
|
|