简体   繁体   English

链接到SQL Server的访问权限显示#Name? 在过滤后的字段中

[英]Access linked to SQL Server shows #Name? in fields after filtering

Regarding: 关于:

  • MS Access 2016 MS Access 2016
  • SQL Server 2017 SQL Server 2017

I have an ODBC connection to a local SQL Server. 我有到本地SQL Server的ODBC连接。 Works like a charm. 奇迹般有效。 Two of the linked tables are made as views. 将其中两个链接表作为视图。 When I open the view in MS Access, it shows figure 1. When I apply a filter, I get the results shown in figure 2, with error in all fields as #Name? 当我在MS Access中打开视图时,它显示如图1所示。应用过滤器后,我得到如图2所示的结果,所有字段中的错误均显示为#Name?

It works perfectly fine when I look it up directly in SQL Server. 当我直接在SQL Server中查找时,它的工作原理就很好。

Any suggestions? 有什么建议么?

图。1

图2

Add what is called a "row version" column to the table. 在表中添加所谓的“行版本”列。 So, create a timestamp column in the base table that the view is based on. 因此,在视图所基于的基表中创建一个timestamp列。 Now include that new column - useally I call it TS, but it is going to be of type "timestamp" - not to be confused with a date/time column. 现在包括该新列-我通常将其称为TS,但它的类型将是“时间戳”-不要与日期/时间列混淆。

The table likely has 1 or more floating point columns, or perhaps a timestamp column. 该表可能具有1个或多个浮点列,或一个timestamp列。 So, add the timestamp column to the base table. 因此,将timestamp列添加到基表中。 Add the TS column to the view, and then re-link the view (or refresh -don't forget this last step). 将TS列添加到视图,然后重新链接视图(或刷新-不要忘记最后一步)。

When you link the view (manually with the access UI), you are given a one-time chance to select the PK column. 链接视图时(手动使用访问UI),将有一次机会选择PK列。 You should not necessary need to set (choose) the PK column, but if you don't, then the table will be read only (and that is fine). 您不需要设置(选择)PK列,但是如果没有,则该表将是只读的(那很好)。

If above TS column does not fix this, then do try choosing a PK when you link (so, a refresh will not suffice, you have to delete and re-create the linked view to get (force/trigger) that all important prompt for the PK. As noted, adding a TS column should fix this, but if it does not, then start over, and re-create the linked view with both a PK selected, and also that all important TS column. If you don't include the TS column, then Access (client side) will do a ugly field by field compare - using a TS column will eliminate this extra work, and rather likely your issue. 如果上面的TS列不能解决此问题,请在链接时尝试选择一个PK(因此刷新将无法满足要求,您必须删除并重新创建链接的视图才能获得(强制/触发)所有重要提示如前所述,添加TS列应该可以解决此问题,但如果不行,请重新开始,然后重新创建链接视图,同时选择PK和所有重要的TS列。包含TS列,然后Access(客户端)将逐个字段进行比较比较丑陋-使用TS列将消除这种额外的工作,并且很可能是您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM