MS Access错误"ODBC-调用失败.强制转换规范(#0)的字符值无效" [英] MS Access error "ODBC--call failed. Invalid character value for cast specification (#0)"

查看:165
本文介绍了MS Access错误"ODBC-调用失败.强制转换规范(#0)的字符值无效"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道这个错误是什么意思或如何解决?我正在使用Access 2003和SQL2005.尝试在特定子窗体上添加记录时出现.

Does anyone have an idea what this error means or how to solve it? I am using Access 2003 and SQL2005. It comes up when trying to add a record on a particular subform.

[Microsoft] [SQL Native Client]强制转换规范(#0)的字符值无效

此MS错误报告描述了相同的消息,但这是SQL Server中的错误6.5已经解决.

This MS bug report describes the same message, but it is a bug in SQL Server 6.5 that has already been solved.

已解决::显然,目标表上没有PK导致了此问题,它与子表单或Access中的查询无关. 我什至都不知道该数据库中没有PK 的表.将PK添加到目标表即可解决该问题.奇怪的是,通过SQL本机客户端执行的错误查询字符串与通过SSMS执行的没有错误的错误查询字符串相同.希望这对遇到该奇怪消息的其他人有所帮助.

Solved: Apparently having no PK on the destination table was causing this, it didn't have anything to do with the subform or the query from Access. I wasn't even aware there were tables in this database without PK. Adding PK to the destination table solved it. The strange thing is the same query string that errored when executed via SQL native client, executed through SSMS with no errors. Hope this helps anyone else who has come across that strange message.

推荐答案

哼,我会在访问侧检查默认的文本框.我还将在设计模式下显示链接表,并且您想检查ms-access在此处假定的数据类型.对于不支持的数据类型,ms-access通常将使用字符串,而sql server可能需要其他内容.

Hum, I would check the text box default on the access side. I would also bring up the linked table in design mode, and you want to check the data type that ms-access assumes here. For non supported data types ms-access will generally use a string, and sql server might be wanting something else.

因此,请同时检查主表中的主键(PK),然后检查子表中用于外键(FK)列的数据类型(假定).进行此操作时,请检查子表单控件(不是表单,不是子表单,而是您的表单中用于链接这两个表的子表单控件)中用于子/主链接设置的表达式).

So, check both the Primary key (PK) in main table, and then check the data type used (assumed) in the child table for the foreign key (FK) column. While we are at this, check your expressions used for the child/master link settings in the sub-form control (not the form, not the sub-form, but the sub-form control used in your form that links up these two tables).

如果您在sql server表中没有timestamp列,则访问中的子表单会很敏感.如前所述,检查PK和FK数据类型并确保它们匹配(只需在ms-access中以设计模式调出表-您会收到一条有关只读设计模式的错误消息,但请继续进行下去,以便您可以检查/查看以确保数据类型匹配).

Sub forms in access are sensitive if you don’t have a timestamp column in the sql server table. As mentioned check the PK and the FK data types and make sure they match up (just bring up the tables in design mode in ms-access -- you get an error message about the design mode being read only, but just continue on so you can check/view to ensure the data types match up).

因此,对于子表,您需要一个PK,一个FK以及一个timestamp列(您不必在子表单中显示TS列,但在表中需要它).

So for the child table, you need a PK, a FK, and also a timestamp column (you don’t have to display the TS column in the sub-form, but you need it in the table).

ms-access中的子表单很敏感,如果您在sql表中不包含timestamp列,则该子表单通常会失败. (Access使用这些行版本列来确定数据是否已更改).

Sub-forms in ms-access are sensitive and often fail if you don’t include a timestamp column in the sql table. (access uses these row version columns to determine if the data been changed).

这篇关于MS Access错误"ODBC-调用失败.强制转换规范(#0)的字符值无效"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆