One*_*elt 1 sql coldfusion datetime sql-server-2008 coldfusion-9
我到处都看了,我找不到答案.
这是我使用ColdFusion和MsSQL的错误
Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Conversion failed when converting date and/or time from character string.
The error occurred in SQL
INSERT INTO Requests (
RequestName,
RequestEmail,
RequestPhone,
RequestType,
RequestSiteSection,
RequestDue,
RequestUrgent,
RequestTitle,
RequestURL,
RequestMessage,
Attachment1,
Attachment2,
Attachment3,
Attachment4,
Attachment5,
RequestCreated,
RequestModified,
RequestPriority,
RequestAssignedTo,
RequestStatus
)
VALUES (
'',
'Joshua >Davis',
'onebigcelt@gmail.com',
'8046789',
'Correction',
'Natural Heritage',
'09/11/2013',
'This is the Title of the REQUEST!',
'http://www.dcr.virginia.com',
'rewas',
'/opt/coldfusion8/runtime/servers/coldfusion/SERVER-INF/temp/wwwroot-tmp/neotmp47128.tmp',
'',
'',
'',
'',
(param 1),
(param 2),
'0',
'Webmaster',
'Pending'
)
Run Code Online (Sandbox Code Playgroud)
每个参数都是 cfqueryparam cfsqltype='CF_SQL_timestamp' value='#CreateODBCDateTime(now())#'
当我尝试使用以下任何一个插入时出现此错误
我已经尝试将时间和日期连接在一起,投射并转换为日期时间,形成日期和时间但没有运气我被卡住了.
我感谢您的帮助.
这是查询
INSERT INTO Requests (
RequestName,
RequestEmail,
RequestPhone,
RequestType,
RequestSiteSection,
RequestDue,
RequestUrgent,
RequestTitle,
RequestURL,
RequestMessage,
Attachment1,
Attachment2,
Attachment3,
Attachment4,
Attachment5,
RequestCreated,
RequestModified,
RequestPriority,
RequestAssignedTo,
RequestStatus
)
VALUES(
'<cfif IsDefined('form.requestUrgent')>#form.requestUrgent#</cfif>',
'#form.requestName#',
'#form.requestEmail#',
'#form.requestPhone#',
'#form.requestType#',
'#form.requestSection#',
'#form.requestDueDate#',
'#form.requestTitle#',
'#form.requestURL#',
'#form.requestMessage#',
'#form.attachment1#',
'#form.attachment2#',
'#form.attachment3#',
'#form.attachment4#',
'#form.attachment5#',
getdate(),
getdate(),
'0',
'Webmaster',
'Pending'
)
Run Code Online (Sandbox Code Playgroud)
您可以getDate()使用上述任何选项#var#转换为cast,param等
从评论
插入查询中的列和值似乎在示例代码中处于关闭状态.您的插入以列开头,RequestName但VALUES子句中的第一个变量是form.requestUrgent然后form.requestName等等.因此,您的查询尝试插入form.requestSection(在您的示例中为"自然遗产")到日期列RequestDue.
摘自你的例子:
INSERT INTO Requests (
RequestName, /* column 1 */
RequestEmail, /* column 2 */
RequestPhone, /* column 3 */
RequestType, /* column 4 */
RequestSiteSection, /* column 5 */
RequestDue, /* column 6 */
RequestUrgent, /* column 7 */
RequestTitle, /* column 8 */
....
VALUES (
'<cfif IsDefined('form.requestUrgent')>#form.requestUrgent#</cfif>', /* value 1 */
'#form.requestName#', /* value 2 */
'#form.requestEmail#', /* value 3 */
'#form.requestPhone#', /* value 4 */
'#form.requestType#', /* value 5 */
'#form.requestSection#', /* value 6 */
'#form.requestDueDate#', /* value 7 */
'#form.requestTitle#', /* value 8 */
....
Run Code Online (Sandbox Code Playgroud)
而且我不能强调你应该<cfqueryparam>为所有变量值使用标签.它有助于防止SQL注入,还可以提高查询性能.
| 归档时间: |
|
| 查看次数: |
1321 次 |
| 最近记录: |