ColdFusion更新到Access数据库"参数太少"

时间:2014-11-26 20:19:33

标签: ms-access coldfusion

我在Access表中添加了一个名为AssignedDate的新字段,数据类型为date / time。然后我将其添加到现有的更新查询中,我收到此错误:

  

[Macromedia] [SequeLink JDBC驱动程序] [ODBC套接字] [Microsoft] [ODBC   Microsoft Access驱动程序]
参数太少。预期1.

     

UpdatedDate = #Now()#,AssignedDate = #Now()#503:WHERE RequestID =   '#arguments.RequestID#'
  504:</cfquery>
  505:</cffunction>
  SQL:   UPDATE Requests_Main SET CADOperatorID = '', EngineerID = 'EAGLE', RequestStatusID = '1', AssingedDate = {ts '2014-11-26 12:50:02'}, UpdatedDate = {ts '2014-11-26 12:50:02'}, AssignedDate = {ts '2014-11-26 12:50:02'} WHERE RequestID = '13999'
DATASOURCE XXX   
VENDORERRORCODE -3010
SQLSTATE 07002

所有内容拼写正确,数据类型匹配,但不会更新。

如果有人可以帮助解释原因,我会非常感激。

除了添加新字段之外,这是没有任何更改的查询。我尝试在变量周围添加单引号,但缺少这些变量,但这也没有用。

`<cffunction name="UpdateRequest_Assignments" access="public" output="false">
    <cfargument name="RequestID" type="numeric" required="true">
        <cfargument name="CADOperatorID" type="string" required="true">
        <cfargument name="EngineerID" type="string" required="true">
        <cfargument name="RequestStatusID" type="numeric" required="true">

            <cfquery datasource="#request.DSN#">
                UPDATE Requests_Main
                SET CADOperatorID = '#arguments.CADOperatorID#',
                EngineerID = '#arguments.EngineerID#',
                RequestStatusID = #arguments.RequestStatusID#,
                AssingedDate = #Now()#,
                UpdatedDate = #Now()#,
                AssignedDate = #Now()#
                WHERE RequestID = #arguments.RequestID#
            </cfquery>

2 个答案:

答案 0 :(得分:1)

我认为@hansup就在这里。您可能没有将新列命名为#34; asingeddate。&#34;同时如果您认为它是asigneddate,那么为什么您的更新中会列出两次该列?这也会导致错误吗?

答案 1 :(得分:1)

我认为问题是您在单个查询中更新了相同的列2次。检查您的更新声明相同列&#39; AssingedDate&#39;列出两次。删除它,然后再试一次。而且,我会在更新表时使用cfqueryparam。最佳实践:)。

                <cfquery datasource="#request.DSN#">
                    UPDATE Requests_Main
                    SET   CADOperatorID = <cfqueryPARAM value = "#arguments.CADOperatorID#" CFSQLType = 'CF_SQL_VARCHAR'>  ,
                          EngineerID = <cfqueryPARAM value = "#arguments.EngineerID#" CFSQLType = 'CF_SQL_VARCHAR'>,
                          RequestStatusID = <cfqueryPARAM value = "#arguments.RequestStatusID#" CFSQLType = 'CF_SQL_NUMERIC'> ,
                          AssingedDate = <cfqueryPARAM value = "#Now()#" CFSQLType = 'CF_SQL_TIMESTAMP'>,
                          UpdatedDate = <cfqueryPARAM value = "#Now()#" CFSQLType = 'CF_SQL_TIMESTAMP'>,
                    WHERE RequestID = <cfqueryPARAM value = "#arguments.RequestStatusID#" CFSQLType = 'CF_SQL_NUMERIC'>
                </cfquery>