这个查询有什么问题吗?

发布于 2024-07-05 15:51:52 字数 1829 浏览 6 评论 0原文

INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]')

我有一个 Access 表,它有五个字段:id、ename、position、phone 和 email...每个字段都是 50 个字符的纯文本字段,除了 255 个字符的position 和一个自动增量字段 id。 我使用 VB.NET 从 Excel 表中读取数据,该数据被推送到一个用于填写该查询的简单类中。 我对另外两个表做了同样的事情,它们的数据是从 DB2 表和 MySQL 表中提取的。 另外两个可以工作,但是这个简单的 INSERT 循环一直失败,所以我不认为是我的“InsertNoExe”函数处理所有 OleDb 的东西。

那么,嗯,该查询、任何字段标题等看起来是假的吗? 如果有人想看的话,我可以发布其他代码。

编辑:已修复。 我不确定宽图像是否算作堆栈溢出错误,这就是我离开它的原因。

编辑2:我很笨。 我使用 try...catch 来查看虚假查询,甚至不检查 ex.messsage。 嘎。

INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]')

   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
   at EmployeeList.EmployeeDatabase.ExeNonQuery(String sql) in C:\andy\html\code\vb\EmployeeList\EmployeeDatabase.vb:line 263

Syntax error in INSERT INTO statement.

编辑3:谢谢你,克里斯。

INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]')

I've got an Access table that has five fields: id, ename, position, phone, and email...each one is plain text field with 50 characters, save for position which is 255 and id which is an autoincrement field. I'm using a VB.NET to read data from an Excel table, which gets pushed into a simple class that's used to fill out that query. I do the same thing with two other tables, whose data are pulled from a DB2 table and a MySQL table through. The other two work, but this simple INSERT loop keeps failing, so I don't think it's my "InsertNoExe" function that handles all the OleDb stuff.

So, um, does that query, any of the field titles, etc. look bogus? I can post other bits of code if anyone wants to see it.

EDIT: Fixed. I wasn't sure if the wide image counted as a Stack Overflow bug or not, which is why I left it.

EDIT 2: I'm dense. I use a try...catch to see the bogus query, and don't even check the ex.messsage. Gah.

INSERT INTO tblExcel (ename, position, phone, email) VALUES ('Burton, Andrew', 'Web Developer / Network Assistant', '876-9259', '[email protected]')

   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
   at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
   at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
   at EmployeeList.EmployeeDatabase.ExeNonQuery(String sql) in C:\andy\html\code\vb\EmployeeList\EmployeeDatabase.vb:line 263

Syntax error in INSERT INTO statement.

EDIT 3: Thank you, Chris.

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

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

发布评论

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

评论(2

梦屿孤独相伴 2024-07-12 15:51:52

我相信“位置”是一个保留词。

尝试...

插入 tblExcel (ename, [position],phone, email) VALUES (...

保留字

I beleive "position" is a reserved word.

Try...

INSERT into tblExcel (ename, [position], phone, email) VALUES (...

Reserved Words

扭转时空 2024-07-12 15:51:52

“Web Developer / Network Assistant”的间距看起来有点奇怪,也许里面有一个隐藏的字符(回车?)

我会尝试将斜杠去掉,看看插入是否有效,如果不行,请尝试采用所有标点符号出去。 然后将其添加回来,也许您就能识别出错误。

The spacing of "Web Developer / Network Assistant" looks a little wonky, maybe there is a hidden character in there (carriage return?)

I'd try taking the slash out, and see if the insert works, if not try taking all punctuation out. Then add it back and maybe you will be able to identify the bug.

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