简体   繁体   English

Azure SQL表 - > SQL Server视图 - >链接访问表:无法更新

[英]Azure SQL Table -> SQL Server View -> Linked Access table: can't update

So I have this cute daisy chain: 所以我有这个可爱的菊花链:

  • A Table in an Azure SQL Database (tblAzure) Azure SQL数据库中的表(tblAzure)
  • A View to tblAzure in a local SQL Server database (vwSQL) 本地SQL Server数据库中的tblAzure视图(vwSQL)
  • A linked table in Access pointing to vwSQL (tblAccess) Access中的链接表指向vwSQL(tblAccess)

Although parts work individually, I can't update the Azure table from Access. 虽然部分单独工作,但我无法从Access更新Azure表。

The connection between the databases work properly individually. 数据库之间的连接可以单独正常工作。 I can update tblAzure by inserting values into vwSQL. 我可以通过在vwSQL中插入值来更新tblAzure。 I can also update tables in SQL server via linked Access tables, or even tables by creating a view to them and linking Access to that view. 我还可以通过链接的Access表更新SQL服务器中的表,甚至可以通过创建视图并将Access链接到该视图来更新表。 I can also see the values in tblAzure through vwSQL opened in Access as a linked table. 我还可以通过在Access中打开的vwSQL看到tblAzure中的值作为链接表。

This is the error I get back when I try to update or append the linked view: 当我尝试更新或附加链接视图时,这是我得到的错误:

ODBC--insert on a linked table 'tblAccess' failed. ODBC - 在链接表'tblAccess'上插入失败。

[Microsoft][ODBC SQL Server Driver][SQL Server]OLE DB provider "SQLNCLI11" for linked server "azw" returned message "The parameter is incorrect:.".(#7412) [Microsoft] [ODBC SQL Server驱动程序] [SQL Server] OLE DB提供程序“SQLNCLI11”用于链接服务器“azw”返回消息“参数不正确:。”。(#7412)
[Microsoft][ODBC SQL Server Driver][SQL Server]OLE DB provider "SQLNCLI11" for linked server "azw" reported an error. [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]链接服务器“azw”的OLE DB提供程序“SQLNCLI11”报告错误。 One or more arguments were reported invalid by the provider. 提供者报告一个或多个参数无效。 (#7399) (#7399)
[Microsoft][ODBC SQL Server Driver][SQL Server]The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "azw" was unable to begin a distributed transaction. [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]无法执行该操作,因为链接服务器“azw”的OLE DB提供程序“SQLNCLI11”无法启动分布式事务。 (#7391) (#7391)

Anyone seen anything like this? 有人见过这样的事吗? I tried changing the link properties/Server Options / Distributor to True, it didn't help. 我尝试将链接属性/服务器选项/分发服务器更改为True,但没有帮助。

The basic idea is that I need a table that is perfectly synced in both our databases, and one that can be edited by our users in Access. 基本思想是我需要一个在我们的数据库中完全同步的表,以及可由Access中的用户编辑的表。 (Don't ask, I inherited a way too overcomplicated system...) (不要问,我继承了太复杂的系统......)


Test scripts 测试脚本

In Azure: 在Azure中:

CREATE TABLE [dbo].[AzureTable](
    [AzureTableID] [int] NOT NULL,
    [SomeText] [nvarchar](50) NULL,
 CONSTRAINT [PK_AzureTable] PRIMARY KEY CLUSTERED ([AzureTableID] ASC)
 WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO

INSERT dbo.AzureTable VALUES (1, N'Hello')

In SQL Server: 在SQL Server中:

(AZW is the name of the linked Azure server, HUFU is the DB) (AZW是链接的Azure服务器的名称,HUFU是数据库)

CREATE VIEW dbo.SQLServerView
AS
SELECT *
FROM AZW.HUFU.dbo.AzureTable
GO

INSERT INTO dbo.SQLServerView values (2,'working')

This is working too. 这也有效。

In Access, I link the view (I have many other linked tables and views, they all work). 在Access中,我链接视图(我有许多其他链接的表和视图,它们都工作)。 Opening the Access linked table (pointing to the SQL server view) it shows the data, but can't save the modifications, displaying the above mentioned error. 打开Access链接表(指向SQL服务器视图)它显示数据,但无法保存修改,显示上述错误。

I actually have a workaround now, but this thing is bugging me, I'd love to understand what's wrong here... 我现在实际上有一个解决方法,但这件事让我烦恼,我很想知道这里有什么问题......

I am not sure this will apply to your case but the last time I was unable to update an SQL Server View from MS Access the solution was to make sure the Access linked table that represented the view had a primary key. 我不确定这是否适用于您的情况,但上次我无法从MS Access更新SQL Server视图时,解决方案是确保代表该视图的Access链接表具有主键。

This is what I use to create the PK: 这就是我用来创建PK的方法:

CurrentDb.Execute "CREATE INDEX __uniqueindex ON [" & TableName & "](" & PKFieldName & ")"

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

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