关于0x80040e14错误
2008-02-23 05:25:56来源:互联网 阅读 ()
This error is thrown up by the underlying OLEDB Provider. The actual error message is:
The command contained one or more errors
The error message that you see on the screen will vary depending on the MDAC that you have installed and the actual cause of the error.
There are a number of possible causes:
Scenario 1 - Syntax error in FROM clause
Scenario 2a - Syntax error in INSERT INTO statement
Scenario 2b - Syntax error in UPDATE statement
Scenario 3a - Syntax error (missing operator) - caused by ' mark
Scenario 3b - Syntax error (missing operator) - incorrect delimiters
Scenario 4 - Syntax error - division by zero error
Scenario 1 - Syntax error in FROM clause
This commonly occurs when you have a table name that is a reserved word or your table name contains a space (eg "table 1").
Certain words (like table, field, date, select, password, level etc) are reserved by either ADO, OLEDB or by Access for use as commands or system objects.
You can get a list of reserved words in Access from the online help. The Microsoft Platform SDK outlines ADO/OLEDB reserved words.
You should never use these words as names for tables or fields nor should you have spaces in your tablenames. It is recommended that you rename your offending tables/fields and adjust your SQL statement accordingly.
If this is not possible you should enclose your offending table names with [ ] marks, eg
SELECT field1
FROM [table]
Scenario 2a - Syntax error in INSERT INTO statement.
This commonly occurs when your field name is a reserved word (see scenario 1 above). Adjust your field names and SQL statement accordingly and you should avoid the problem.
If you can't adjust your fieldnames you can use [ ] marks to delimit the field names, eg
INSERT INTO table1
([field], [password])
VALUES ('value1', 'value2')
Scenario 2b - Syntax error in UPDATE statement.
This has the same cause as Scenario 2a immediately above.
Scenario 3a - Syntax Error (Missing Operator)
This is commonly caused when some value that you are trying to SELECT/UPDATE etc contains a single quote mark. The error that you receive looks like:
Microsoft JET Database Engine (0x80040e14)
Syntax error (missing operator) in query expression 'Name = 'O'Malleys''.
Because of the presence of the ' in the name O'Malleys the database engine thinks that you are constructing a WHERE clause like:
WHERE name = 'O'
and doesn't know what to do with the rest of the name (Malleys). To solve this problem you need to use the Replace() function and replace all single quotes with two single quotes. It is recommended that you put the Replace() function above into a user-defined function and call as necessary within your page. Click here for an example of such a function.
Scenario 3b - Syntax Error (Missing Operator) - incorrect delimiters
This error can also be caused when attempting an INSERT or UPDATE SQL statement and you have used incorrect delimiters.
Field Type (Access) Field Type (SQL Server) Delimiter
Text Char, varChar '
Numeric Any numeric type <none>
Date/Time Any Date/Time # (Access), ' (SQL Server)
UPDATE table1
SET someTextField = 'someTextValue',
someNumericField = 5
someDateField = #01/01/2000#
Scenario 4 - Division by Zero
Dates need to be delimited with # marks when passed to the Jet Database Engine. This marks them as a date literal. Access then takes the literal date and converts it into a number. Alternatively, you can pass an integer to Access, and Access will construct a date based on that number.
However if you do this:
SELECT field1
FROM table1
WHERE field1 = 01/01/00
Access will treat this as an integer - namely 1 divided by 1 divided by 0, resulting in a division by zero error. Instead you need to write your SELECT query as:
SELECT field1
FROM table1
WHERE field1 = #01/01/00#
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:rs的pagesize属性
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash