1/1/1900 [英] 1/1/1900

查看:93
本文介绍了1/1/1900的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当表单字段(输入类型=文本)留空时,它将1/1/1900存储在

SQL Server DB中的字段中。我不知道为什么。


SQL Server中的字段是日期/时间字段。我可以把varchar或

类似的东西,但我需要稍后在

项目中对这些日期做数学。


我尝试通过这样做将事物转换为日期:


strTempSolution = CDate(Trim(Request.Form(" TempSolution))))

或者

strTempSolution = DateValue(Trim(Request.Form(TempSolution)))


但我得到了指向那些行的类型不匹配错误:

=======================

类型不匹配:''DateValue''


/CloseTicket.asp,第124行

=======================


奇怪的是,DateValue似乎在

代码的另一部分中运行良好,与此无关,但是在同一个ASP上页。差异

是在该字段中,我使用Now预填充文本字段,其具有

日期和时间。但是,在上面提到的字段中,用户通过以下格式键入

日期:mm / dd / yyyy。


这在以下情况下工作正常日期已输入网络表单。当它将1/1/1900插入数据库的空白时,它只有

。当我说它工作正常时,我在没有DateValue或Cdate或任何类型的尝试

转换时讨论
。我希望它输入NULL,或者不输入任何内容。

When a form field (input type=text) is left blank, it stores 1/1/1900 into
the field in the SQL Server DB. I''m not sure why.

The field in SQL Server is a date/time field. I could make it varchar or
something similar, but I will need to do math with these dates later in the
project.

I tried converting the thing to date by doing this:

strTempSolution = CDate(Trim(Request.Form("TempSolution")))
or
strTempSolution = DateValue(Trim(Request.Form("TempSolution")))

but I got type mismatch errors pointing to those very lines:
=======================
Type mismatch: ''DateValue''

/CloseTicket.asp, line 124
=======================

What''s weird is that the DateValue seems to work fine in another part of the
code that''s unrelated to this, but is on the same ASP page. The difference
is that in that field, I prefill the text field with Now, which has both a
date and time. In the above-referenced field, however, the user types the
date in via this format: mm/dd/yyyy.

This works fine when a date has been entered into the web form. It''s only
when blank that it inserts 1/1/1900 into the DB. When I say it works fine, I
am talking about without the DateValue or Cdate or any type of attempted
conversion. I''d like it to enter NULL, or not enter anything.

推荐答案

检查它是否为空并传递NULL。确保你的数据库没有默认值

并允许NULL但是......

-

Curt Christianson

网站: http://www.Darkfalz.com

博客: http://blog.Darkfalz.com

middletree < MI ******** @ htomail.com>在消息中写道

news:OT ************** @ TK2MSFTNGP11.phx.gbl ...
Check if its blank and pass NULL. Make sure your DB doesn''t have a default
and allows NULL though...
--
Curt Christianson
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"middletree" <mi********@htomail.com> wrote in message
news:OT**************@TK2MSFTNGP11.phx.gbl...
当表格字段时(输入类型=文本)留空,它将1/1/1900存储在SQL Server数据库的字段中。我不知道为什么。

SQL Server中的字段是日期/时间字段。我可以把它变成varchar或类似的东西,但我将需要在

项目中对这些日期进行数学计算。

我尝试将这个日期转换为这样做的日期:

strTempSolution = CDate(Trim(Request.Form(" TempSolution)))

strTempSolution = DateValue(Trim(Request.Form) ; TempSolution)))

但我得到的类型不匹配错误指向那些行:
==================== ===
类型不匹配:''DateValue''

/CloseTicket.asp,第124行
================ =======

有点奇怪的是,DateValue似乎在
与此无关的代码的另一部分工作正常,但是在同一个ASP页面上。差异
是在该字段中,我使用Now预填充文本字段,其具有
日期和时间。但是,在上面引用的字段中,用户通过以下格式键入
日期:mm / dd / yyyy。

当在Web表单中输入日期时,此工作正常。只有空白才能将1/1/1900插入数据库。当我说它工作正常时,
我正在谈论没有DateValue或Cdate或任何类型的尝试
转换。我希望它输入NULL,或者不输入任何内容。
When a form field (input type=text) is left blank, it stores 1/1/1900 into
the field in the SQL Server DB. I''m not sure why.

The field in SQL Server is a date/time field. I could make it varchar or
something similar, but I will need to do math with these dates later in
the
project.

I tried converting the thing to date by doing this:

strTempSolution = CDate(Trim(Request.Form("TempSolution")))
or
strTempSolution = DateValue(Trim(Request.Form("TempSolution")))

but I got type mismatch errors pointing to those very lines:
=======================
Type mismatch: ''DateValue''

/CloseTicket.asp, line 124
=======================

What''s weird is that the DateValue seems to work fine in another part of
the
code that''s unrelated to this, but is on the same ASP page. The difference
is that in that field, I prefill the text field with Now, which has both a
date and time. In the above-referenced field, however, the user types the
date in via this format: mm/dd/yyyy.

This works fine when a date has been entered into the web form. It''s only
when blank that it inserts 1/1/1900 into the DB. When I say it works fine,
I
am talking about without the DateValue or Cdate or any type of attempted
conversion. I''d like it to enter NULL, or not enter anything.



当我做一个response.write时我应该添加SQL语句,我得到:


UPDATE TKT_Ticket SET StatusID =''1'',DefectNum ='''',Files =

''' ',Contact_CustID ='''641'',Current_Source =

''E'',LastModified ='''12/29/2004'',CustTicketID ='''333'',TempSolution ='' '',

ProbIdentified =''12/02/2004'',SolutionIdentified =''12/03/2004'',

SolutionImplemented =''12/04 / 2004'',RootCause =''256''WHERT TKT_TicketID =

''16184''


关键是这一部分:

TempSolution ='''',


它表明它输入的是空白值。所以到那时为止,它是
工作正常。
I should add that when I do a response.write of the SQL statement, I get:

UPDATE TKT_Ticket SET StatusID = ''1'',DefectNum = '''' ,Files=
'''',Contact_CustID = ''641'' ,Current_Source =
''E'',LastModified=''12/29/2004'',CustTicketID = ''333'', TempSolution='''',
ProbIdentified = ''12/02/2004'', SolutionIdentified=''12/03/2004'',
SolutionImplemented=''12/04/2004'',RootCause = ''256'' WHERE TKT_TicketID =
''16184''

The key is this part:
TempSolution='''',

It demonstrates that it is entering a blank value. So up to that point, it
is working correctly.


不通过''''

传递NULL

-

Curt Christianson

网站: http://www.Darkfalz.com

博客: http://blog.Darkfalz.com

" middletree" < MI ******** @ htomail.com>在留言中写道

news:un ************** @ TK2MSFTNGP14.phx.gbl ...
dont pass ''''
pass NULL
--
Curt Christianson
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"middletree" <mi********@htomail.com> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...
我应该补充一下我做了一个SQL语句的response.write,我得到:

UPDATE TKT_Ticket SET StatusID =''1'',DefectNum ='''',Files =
'''' ,Contact_CustID ='''641'',Current_Source =
''E'',LastModified ='''12/29/2004'',CustTicketID ='''333'',TempSolution ='''',
ProbIdentified ='''年票/ 02/2004'',SolutionIdentified =''12/03/2004'',
SolutionImplemented ='''12/04/2004'',RootCause ='''256''在哪里TKT_TicketID =
''16184''

关键是这一部分:
TempSolution ='''',

它表明它正在进入一个空白值。所以到目前为止,它正在正常工作。
I should add that when I do a response.write of the SQL statement, I get:

UPDATE TKT_Ticket SET StatusID = ''1'',DefectNum = '''' ,Files=
'''',Contact_CustID = ''641'' ,Current_Source =
''E'',LastModified=''12/29/2004'',CustTicketID = ''333'', TempSolution='''',
ProbIdentified = ''12/02/2004'', SolutionIdentified=''12/03/2004'',
SolutionImplemented=''12/04/2004'',RootCause = ''256'' WHERE TKT_TicketID =
''16184''

The key is this part:
TempSolution='''',

It demonstrates that it is entering a blank value. So up to that point, it
is working correctly.



这篇关于1/1/1900的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆