INSERT INTO 语句包含以下未知字段名称

发布于 2024-10-31 16:29:23 字数 1768 浏览 0 评论 0原文

我在 Windows 7 64 位上使用 Coldfusion 9,0,0,251028,并使用 Microsoft Access 97 数据库。

当我运行此查询时:

<cfquery name="put_in_info" datasource="#db#">

      insert into news

                  (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat)

      values

  (1,1, #createodbcdate(now())#, #createodbctime(now())#, '#subject#', '#message#',1, #session.expdate#)

</cfquery>

我收到此错误:

Error Executing Database Query.

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: 'exp_dat'. Make sure you have typed the name correctly, and try the operation again.   The error occurred in H:\Inetpub\pvalert.com\listserver\admin\templates\post_breaking.cfm: line 26
Called from H:\Inetpub\pvalert.com\listserver\admin\new_process.cfm: line 54
Called from H:\Inetpub\pvalert.com\listserver\admin\templates\post_breaking.cfm: line 26
Called from H:\Inetpub\pvalert.com\listserver\admin\new_process.cfm: line 54

24 :      (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat)

25 :   values

26 :   (1,1, #createodbcdate(now())#, #createodbctime(now())#, '#subject#', '#message#',1, #session.expdate#)

27 :    </cfquery>

28 :

VENDORERRORCODE


  -1507

SQLSTATE


  HYS22

SQL


   insert into news (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat) values (1,1, {d '2011-04-11'}, {t '17:49:09'}, 'Test message - please ignore', 'This is a test message, please ignore. ',1, {ts '2011-05-15 00:00:00'})

DATASOURCE


  rpv_list

Exp_dat 是我需要更新的表中的到期日期列。

我尝试删除“会话”。在 expdate 变量上,那什么也没做。同样,删除第 24 行“exp_dat”周围的任何空格。

I’m using Coldfusion 9,0,0,251028 on Windows 7 64-bit, with a Microsoft Access 97 database.

When I run this query:

<cfquery name="put_in_info" datasource="#db#">

      insert into news

                  (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat)

      values

  (1,1, #createodbcdate(now())#, #createodbctime(now())#, '#subject#', '#message#',1, #session.expdate#)

</cfquery>

I get this error:

Error Executing Database Query.

[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: 'exp_dat'. Make sure you have typed the name correctly, and try the operation again.   The error occurred in H:\Inetpub\pvalert.com\listserver\admin\templates\post_breaking.cfm: line 26
Called from H:\Inetpub\pvalert.com\listserver\admin\new_process.cfm: line 54
Called from H:\Inetpub\pvalert.com\listserver\admin\templates\post_breaking.cfm: line 26
Called from H:\Inetpub\pvalert.com\listserver\admin\new_process.cfm: line 54

24 :      (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat)

25 :   values

26 :   (1,1, #createodbcdate(now())#, #createodbctime(now())#, '#subject#', '#message#',1, #session.expdate#)

27 :    </cfquery>

28 :

VENDORERRORCODE


  -1507

SQLSTATE


  HYS22

SQL


   insert into news (is_current, display, mes_dat,mes_tim,mes_sub,mes_text,scrollshow,exp_dat) values (1,1, {d '2011-04-11'}, {t '17:49:09'}, 'Test message - please ignore', 'This is a test message, please ignore. ',1, {ts '2011-05-15 00:00:00'})

DATASOURCE


  rpv_list

Exp_dat is an expiration date column in a table that I need to update.

I've tried removing the "session." on the expdate variable, and that did nothing. Likewise for removing the any spaces around line 24's "exp_dat".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦与时光遇 2024-11-07 16:29:23

给出的错误消息不会抱怨插入的值。它指出您的表/视图“新闻”中不存在字段“exp_dat”。

首先要做的是仔细检查是否确实存在名为“exp_dat”的字段。如果您无法直接访问数据库,只需从 ColdFusion 中启动查询并转储查询结果即可。

<cfquery name="getSomeRowsFromNewsTable" datasource="#db#" maxrows="10">
select * from news
</cfquery>
<cfdump var="#getSomeRowsFromNewsTable#" abort="true">

也许有人给字段起了别名,或者没有在视图中包含现有字段,或者它被称为“exp_dattim”,或者......

The error message given doesn't complain about the value inserted. It states that the field "exp_dat" doesn't exist in your table/view "news".

The first thing to do is to double check if there actually is a field named "exp_dat". If you don't have direct access to the database, just fire up a query from within ColdFusion and dump the query result.

<cfquery name="getSomeRowsFromNewsTable" datasource="#db#" maxrows="10">
select * from news
</cfquery>
<cfdump var="#getSomeRowsFromNewsTable#" abort="true">

Maybe someone aliased the field, or did not include an existing field in a view, or it's called "exp_dattim", or ...

_畞蕅 2024-11-07 16:29:23

给定一个 INSERT 查询,例如

INSERT INTO tblname ('column1', 'column2', 'column3' ...) VALUES ...

尝试在列名称周围使用方括号(即 []),如下所示:

INSERT INTO tblname ([column1], [column2], [column3] ...) VALUES ...

这在 Access SQL GUI 解释器中对我有用,但可能无法解决 OP 的特定情况(Coldfusion 等)。

Given an INSERT query, such as

INSERT INTO tblname ('column1', 'column2', 'column3' ...) VALUES ...

Try using square brackets- that's []- around the column names, like so:

INSERT INTO tblname ([column1], [column2], [column3] ...) VALUES ...

This worked for me in the Access SQL GUI Interpreter, but might not solve the OP's specific situation (Coldfusion, etc).

度的依靠╰つ 2024-11-07 16:29:23

我在使用 MS Access 时多次遇到过这个问题。我知道列名称拼写正确并且该列存在。
EG,我可以毫无问题地在列上执行“SELECT”,但是当我尝试简单的 SQL INSERT 时,我收到错误:“...未知的字段名称”
我没有输入任何内容,只是使用复制和粘贴,因此不可能出现拼写错误。从字面上看,Access 确实识别 SELECT 语句中的列名,并且在尝试 INSERT 时无法识别相同的列名。

这似乎是 MS Access 2010 中的一个错误。

I have run into this issues several times , with MS Access. I know the Column name is spelled correctly and that the column exists.
E.G., I can do a 'SELECT' on the column with no problem, but when I try a simple SQL INSERT, I get that error: "... Unknown field name"
I typed nothing, just used copy and paste, so there is no chance of a typo. Access literally does recognize a column name in SELECT statement, and DOES NOT recognize that same column name when attempting an INSERT.

It appears to be a bug in MS Access 2010.

烟凡古楼 2024-11-07 16:29:23

尝试用单引号将插入语句中插入的每个值括起来。例如 '#variable#'、'#another_var#' ——等等。我想我也遇到了同样的问题,但这样做解决了它。

Try to wrap every value you insert in your insert statement with single quotes.ie '#variable#', '#another_var#' -- and so on. I think I had the same problem, but doing that fixed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文