[英]Update to SQL View fails from Access with Linked Table
I have a table that I created a view from. 我有一个表,我创建了一个视图。 The view really doesn't change anything, except the order of the columns and one column is
converted
to a varchar
from an int
. 该视图实际上不会更改任何内容,除了列的顺序和一个列从
int
converted
为varchar
。
The view is set up as a linked table in Access 2013. Everything pulls in just fine. 该视图在Access 2013中设置为链接表。一切都很好。 When I pull up a form in Access to edit rows in the view I get the problem.
当我在Access中拉出一个表单来编辑视图中的行时,我遇到了问题。
I attempt to update the column OSP_PERCENT_COMPLETE
with NA. 我尝试用NA更新
OSP_PERCENT_COMPLETE
列。 The end users want this field to not be only an int
. 最终用户希望此字段不仅仅是
int
。 I updated the view so that it pulls the column like this: 我更新了视图,以便它像这样拉出列:
convert(varchar(10),OSP_PERCENT_COMPLETE) OSP_PERCENT_COMPLETE
So it keeps the same name but is now a varchar
field. 所以它保持相同的名称,但现在是一个
varchar
字段。 Then when I go to update that field in the form I get this error message 然后当我在表单中更新该字段时,我收到此错误消息
ODBC--update on a linked table 'PMDBII' failed Access [Microsoft][ODBC SQL Server Driver][SQL Server] Update or Insert of view or function '' failed because it contains a derived or constant field.
ODBC - 链接表'PMDBII'上的更新失败Access [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]更新或插入视图或函数''失败,因为它包含派生或常量字段。 (#4406)
(#4406)
I can check the field in the PMDBII linked table and it shows it as a short text
field with a length of 10. 我可以检查PMDBII链接表中的字段,并将其显示为长度为10的
short text
字段。
One thing I should mention, most of this was set up by a coworker who is no longer with the company and I'm not as versed in Access as he was. 有一件事我应该提到,其中大部分都是由一位不再与公司合作的同事建立的,我不像他那样精通Access。
So why do I get the error? 那么为什么我会收到错误?
You get the error because a 'view' does not change the fact that the underlying field is still an 'int'. 您会收到错误,因为“视图”不会更改基础字段仍为“int”的事实。 If you use a form, possibly you could include code on a 'before change' event that translates NA to null, but that could be a bad idea.
如果您使用表单,可能您可以在“更改前”事件中包含将NA转换为null的代码,但这可能是一个坏主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.