SQL 您如何解决 MS Access 2010 中的“条件表达式中的数据类型不匹配”错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28155538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:11:26  来源:igfitidea点击:

How do you trouble shoot a "Data type mismatch in criteria expression" error in MS Access 2010?

sqlms-accessms-access-2010

提问by JasonR

I am trying to troubleshoot a Report in an MS Access Database. This file was build by the person that held my role before I joined the organization I work for.

我正在尝试对 MS Access 数据库中的报告进行故障排除。这个文件是由在我加入我工作的组织之前担任我角色的人建立的。

The report is throwing an error "Data type mismatch in criteria expression" This leads me to believe that the data being imported into the DB is not compatible with the data types set in the report's query. There are 53 pieces in the SQL SELECT Statement.

报告抛出错误“条件表达式中的数据类型不匹配”这让我相信导入数据库的数据与报告查询中设置的数据类型不兼容。SQL SELECT 语句中有 53 条。

Is there a good way to trouble shoot the statement (in Access) to find which piece is causing the error? I'm just getting back into using Access so I'm a little rusty.

是否有一种好方法可以解决(在 Access 中)语句的故障,以找出导致错误的部分?我刚刚重新开始使用 Access,所以我有点生疏。

回答by Robert Harvey

The criteria expression is the part of the query containing the conditions, as in WHERE <condition>. Look at those specifically. The error message means you're comparing two things (this equals that, or this less than that, etc.) that are of two different, and incompatible types (comparing a number to a string, for example).

条件表达式是包含条件的查询的一部分,如 WHERE <condition>。具体看那些。错误消息意味着您正在比较两种不同且不兼容的类型(例如,将数字与字符串进行比较)的两件事(等于或小于等)。

You can find out which condition is causing the problem by deleting them one at a time and testing again each time until the error disappears.

您可以通过一次删除一个条件并每次重新测试直到错误消失来找出导致问题的条件。

Make sure you save a copy of your original query, or make a new copy for testing.

确保保存原始查询的副本,或制作新副本进行测试。