数据库条目语法错误

时间:2015-04-21 16:11:00

标签: sql-server coldfusion

我正在尝试使用cfqueryparam(coldfusion 10)将数据插入数据库(sql server 2010)。我不确定我做错了什么,为什么它会抛出这个错误。它说我有语法错误但不告诉我语法错误发生了什么行。任何帮助将不胜感激!

错误

[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near '@P2'.

ColdFusion的

<cfif (isDefined("session.checkout.quantity.pcount"))>
<cfquery datasource="Titlesbymail" name="InsertEntry">
     INSERT INTO Customer (FirstName, LastName)
     VALUES (
        <cfqueryparam value='#session.checkout.info.firstname_1#' cfsqltype='cf_sql_nvarchar' />
       , <cfqueryparam value='#session.checkout.info.lastname_1#' cfsqltype='cf_sql_nvarchar' />
</cfquery>

1 个答案:

答案 0 :(得分:4)

在您的示例中,您缺少右括号。

你有:

<cfquery datasource="Titlesbymail" name="InsertEntry">
 INSERT INTO Customer (FirstName, LastName)
 VALUES (
    <cfqueryparam value='#session.checkout.info.firstname_1#' cfsqltype='cf_sql_nvarchar' />
   , <cfqueryparam value='#session.checkout.info.lastname_1#' cfsqltype='cf_sql_nvarchar' />
</cfquery>

应该是:

<cfquery datasource="Titlesbymail" name="InsertEntry">
 INSERT INTO Customer (FirstName, LastName)
 VALUES (
    <cfqueryparam value='#session.checkout.info.firstname_1#' cfsqltype='cf_sql_nvarchar' />
   , <cfqueryparam value='#session.checkout.info.lastname_1#' cfsqltype='cf_sql_nvarchar' />
 )
</cfquery>

看看是否能解决问题。