不允许更新记录 - 写冲突

时间:2009-06-01 20:54:04

标签: ms-access null default-value sql-server-2008-express

这源于我之前提出的一个问题 - 关于与表单的写冲突,但问题似乎源于我可以更新由一个系统DSN提供的链接表中的现有记录,而不是另一个链接表另一个DSN(不同的数据库)提供的表 - 允许我首先输入记录,但后来阻止我对记录进行任何更改,就像另一个用户在我之前更改了数据一样。服务器上没有为默认值定义检查约束,没有触发器,没有视图,没有其他用户访问同一个表。

两个DSN都设置为IDENTICAL,除了它们打开的默认数据库 - 第一个打开gtdata_test,而第二个打开instkeeper_test。 SQL Server实例上的两个数据库都归我所有,我是唯一登录的用户。

我已对此进行了测试,此问题发生在表级(程序中没有VBA,没有任何内容),手动更新。

如果它有帮助,我将包括好表的CREATE语句,以及它下面的受影响表。我希望有人可以帮助我,因为我是新鲜的想法。

在gtdata_test中创建Supplier_Master表的代码

USE [gtdata_test]
GO

/****** Object:  Table [dbo].[Supplier_Master]    Script Date: 05/27/2009 15:58:17 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Supplier_Master](
    [Supplier_Code] [nvarchar](50) NOT NULL,
    [Supplier_Master_Name] [nvarchar](50) NULL,
    [Salutation] [nvarchar](50) NULL,
    [Contact] [nvarchar](50) NULL,
    [Phone] [nvarchar](50) NULL,
    [Fax] [nvarchar](50) NULL,
    [EMail] [nvarchar](50) NULL,
    [Address] [nvarchar](50) NULL,
    [City] [nvarchar](50) NULL,
    [State] [nvarchar](50) NULL,
    [Zip] [nvarchar](50) NULL,
    [Country] [nvarchar](50) NULL,
    [Last_Review] [datetime] NULL,
    [Last_Rating] [datetime] NULL,
    [Last_Received] [datetime] NULL,
    [Last_Reject] [datetime] NULL,
    [Enabled] [int] NULL,
    [User1] [nvarchar](50) NULL,
    [User2] [nvarchar](50) NULL,
    [SupType] [nvarchar](50) NULL,
 CONSTRAINT [Supplier_Master$PrimaryKey] PRIMARY KEY CLUSTERED 
(
    [Supplier_Code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Address$disallow_zero_length] CHECK  ((len([Address])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Address$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$City$disallow_zero_length] CHECK  ((len([City])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$City$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Contact$disallow_zero_length] CHECK  ((len([Contact])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Contact$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Country$disallow_zero_length] CHECK  ((len([Country])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Country$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$EMail$disallow_zero_length] CHECK  ((len([EMail])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$EMail$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Fax$disallow_zero_length] CHECK  ((len([Fax])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Fax$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Phone$disallow_zero_length] CHECK  ((len([Phone])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Phone$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Salutation$disallow_zero_length] CHECK  ((len([Salutation])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Salutation$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$State$disallow_zero_length] CHECK  ((len([State])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$State$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Supplier_Code$disallow_zero_length] CHECK  ((len([Supplier_Code])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Supplier_Code$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Supplier_Master_Name$disallow_zero_length] CHECK  ((len([Supplier_Master_Name])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Supplier_Master_Name$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$SupType$disallow_zero_length] CHECK  ((len([SupType])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$SupType$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$User1$disallow_zero_length] CHECK  ((len([User1])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$User1$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$User2$disallow_zero_length] CHECK  ((len([User2])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$User2$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master]  WITH NOCHECK ADD  CONSTRAINT [SSMA_CC$Supplier_Master$Zip$disallow_zero_length] CHECK  ((len([Zip])>(0)))
GO

ALTER TABLE [dbo].[Supplier_Master] CHECK CONSTRAINT [SSMA_CC$Supplier_Master$Zip$disallow_zero_length]
GO

ALTER TABLE [dbo].[Supplier_Master] ADD  DEFAULT ((0)) FOR [Enabled]
GO

在instkeeper_test中创建tblSupplierInfo的代码

USE [instkeeper_test]
GO

/****** Object:  Table [dbo].[tblSupplierInfo]    Script Date: 05/27/2009 15:57:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblSupplierInfo](
    [strSupplierID] [nvarchar](50) NOT NULL,
    [bolSupAltShipAddyRep] [bit] NULL,
    [bolSupAltShipAddyCal] [bit] NULL,
    [bolSupInsistNet30] [bit] NULL,
    [bolRMARequireRepair] [bit] NULL,
    [bolRMARequireCalibration] [bit] NULL,
    [bolSupShipOrCourier] [bit] NULL,
    [bolSupRequireMSDS] [bit] NULL,
    [bolSupBlanketPO] [bit] NULL,
    [bolSupRequirePricing] [bit] NULL,
    [bolSupBlankPricing] [bit] NULL,
    [bolSupFaxPOSend] [bit] NULL,
    [bolAdditionalPaperworkRepair] [bit] NULL,
    [bolAdditionalPaperworkCalibration] [bit] NULL,
    [strRMARepairWordage] [nvarchar](100) NULL,
    [strRMACalibrationWordage] [nvarchar](100) NULL,
    [intBlanketPO] [int] NULL,
    [bolUseFedExNumber] [bit] NULL,
    [strFedExNumber] [nvarchar](150) NULL,
    [bolUseUPSNumber] [bit] NULL,
    [strUPSNumber] [nvarchar](150) NULL,
    [bolSupA2LAAccredited] [bit] NULL,
    [bolSupFreightAllow] [bit] NULL,
    [bolSupFreightOnly] [bit] NULL,
    [bolSupUseMiscNum] [bit] NULL,
    [strSupMiscFreightNum] [nvarchar](150) NULL,
 CONSTRAINT [tblSupplierInfo$PrimaryKey] PRIMARY KEY CLUSTERED 
(
    [strSupplierID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

在instkeeper_test中创建tblSupplierNote的代码

USE [instkeeper_test]
GO

/****** Object:  Table [dbo].[tblSupplierNote]    Script Date: 06/01/2009 12:34:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tblSupplierNote](
    [intSupNoteID] [int] IDENTITY(1,1) NOT NULL,
    [strSupplierID] [nvarchar](50) NULL,
    [datDateNoteEntered] [datetime] NULL,
    [datTimeNoteEntered] [datetime] NULL,
    [strNoteBy] [nvarchar](255) NULL,
    [memSupNote] [nvarchar](max) NULL,
 CONSTRAINT [tblSupplierNote$PrimaryKey] PRIMARY KEY CLUSTERED 
(
    [intSupNoteID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[tblSupplierNote]  WITH CHECK ADD  CONSTRAINT [tblSupplierNote$tblSupplierInfotblSupplierNote] FOREIGN KEY([strSupplierID])
REFERENCES [dbo].[tblSupplierInfo] ([strSupplierID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[tblSupplierNote] CHECK CONSTRAINT [tblSupplierNote$tblSupplierInfotblSupplierNote]
GO

概述 - 我使用第一个DSN开发的应用程序中的任何表都是可读/写的,可以创建,删除和更新记录而没有任何问题。使用第二个DSN,我可以将任何引入应用程序的表写入ONCE。任何进一步的更改都将丢失,只要数据表视图中的表中的数据更新,就会出现“写入冲突”对话框。

我正在使用的软件:

  • Microsoft Access 2003
  • SQL Server Express 2008
  • Windows XP Professional SP3

- 编辑于06/03/2009 @ 1307小时 -

我发现使用Yes / No复选框和带有Access的SQL Server时会出现一个奇怪的问题。显然,Access会将NULL解释为否 - 更改值,但SQL Server不会将NULL解释为位字段中的“否”(转换中的“是/否”),因此当值不是时会抛出“写入冲突”错误必需,并且为NULL。解决方案是重新设计表,以便需要一个值,并为每个以前的Yes / No复选框分配一个默认值。这解决了神秘的Write Conflict消息,并允许在创建记录后对记录进行更改。

3 个答案:

答案 0 :(得分:2)

Access如何处理是/否复选框值与SQL Server之间存在差异。将Access / No布尔值从Access转换为SQL Server时,您必须记住定义默认状态并将其标记为需要答案。否则,每次都会出现写入冲突,并且一旦设置了初始值,就会阻止记录与您的更改一起保存。

答案 1 :(得分:1)

您是否尝试删除表格链接并重新创建?对链接到的表/视图的更改可能会导致它们变为只读,除非删除它们并重新创建它们,否则无法更正它。

另外,我使用DSN进行链接,然后使用Doug Steele's code to convert them to DNS-less connection strings.

答案 2 :(得分:1)

当记录包含NULL位数据类型列时,我有与SQL Server的Access前端类似的“写冲突”,我注意到您的表包含,即使您没有更新这些列。将位数据类型列设置为默认值0并将位数据类型为NULL的现有记录更新为0已修复。