Hi,
I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 all
null true
If the user do not enter a date in the text box it is returning a error type
mismatch ever though the field is set to allow Nulls.
What can I do to correct this
Thanks
DibCan you post the datetime format you are using while inserting the data?
Anith|||Check the code that generates an insert from the empty
text box. My guess: the insert is trying to put the empty
string '' into a datetime column. The empty string is not
a valid datetime string.
Steve Kass
Drew University
Dib wrote:
>Hi,
>I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 al
l
>null true
>If the user do not enter a date in the text box it is returning a error typ
e
>mismatch ever though the field is set to allow Nulls.
>What can I do to correct this
>Thanks
>Dib
>
>|||There is no format, however when the form loads if the field is blank I am
inserting "" empty string to the textbox,
if you think this is the problem how can I correct it, When in Debug Mode
the textbox is an "" empty string.
Thanks
Dib
"Steve Kass" <skass@.drew.edu> wrote in message
news:uCEVMAMKFHA.2728@.TK2MSFTNGP10.phx.gbl...
> Check the code that generates an insert from the empty
> text box. My guess: the insert is trying to put the empty
> string '' into a datetime column. The empty string is not
> a valid datetime string.
> Steve Kass
> Drew University
> Dib wrote:
>
all
type|||I don't know. If there is a newsgroup specific to the particular front
end you are using to create this form and connect it with the database,
that might be a better place to ask. If you want a SQL Server solution,
the best I can suggest is to insert into a varchar-type column in a
staging table or use an instead of trigger to capture the form
information and generate an insert after turning '' into NULL. But
neither of these is as good a solution finding a way to create the
correct insert statement. I would expect most front-end programs to
have some kind of control that corresponds more directly to SQL Server
datetime than just a string/text control.
SK
Dib wrote:
>There is no format, however when the form loads if the field is blank I am
>inserting "" empty string to the textbox,
>if you think this is the problem how can I correct it, When in Debug Mode
>the textbox is an "" empty string.
>Thanks
>Dib
>"Steve Kass" <skass@.drew.edu> wrote in message
>news:uCEVMAMKFHA.2728@.TK2MSFTNGP10.phx.gbl...
>
>all
>
>type
>
>
>|||Thanks
Dib
"Steve Kass" <skass@.drew.edu> wrote in message
news:ePzRSXMKFHA.2764@.tk2msftngp13.phx.gbl...
> I don't know. If there is a newsgroup specific to the particular front
> end you are using to create this form and connect it with the database,
> that might be a better place to ask. If you want a SQL Server solution,
> the best I can suggest is to insert into a varchar-type column in a
> staging table or use an instead of trigger to capture the form
> information and generate an insert after turning '' into NULL. But
> neither of these is as good a solution finding a way to create the
> correct insert statement. I would expect most front-end programs to
> have some kind of control that corresponds more directly to SQL Server
> datetime than just a string/text control.
> SK
> Dib wrote:
>
am
8|||You cannot insert "" into a datefield. What I usually do is create a stored
procedure to do the insert with input variables defined that have a default
value of Null. Then from the form, I only send those fields which have a
value. The insert statment in the SP will then give the value of Null to any
variables not sent and insert a Null value into the table for that field.
If you don't want to use an SP, have the form specifically send Null as the
value for the field.
"Dib" wrote:
> Hi,
> I have a table in SQL Server 2000, a field StatDate datatype datatime, 8 a
ll
> null true
> If the user do not enter a date in the text box it is returning a error ty
pe
> mismatch ever though the field is set to allow Nulls.
> What can I do to correct this
> Thanks
> Dib
>
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment