0

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

两个 DSN 都设置相同,除了它们打开的默认数据库 - 第一个打开 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。任何进一步的更改都将丢失,并且每当更新数据表视图中的表中的数据时,就会出现一个写入冲突对话框。

我正在使用的软件:

  • 微软访问 2003
  • SQL Server 速成版 2008
  • Windows XP 专业版 SP3

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

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

4

3 回答 3

2

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

于 2009-06-29T16:05:17.257 回答
1

您是否尝试过删除表格链接并重新创建它们?对您链接到的表/视图的更改可能会导致它们变为只读,并且除了删除它们并重新创建它们之外,没有其他方法可以更正它。

此外,我使用 DSN 进行链接,然后使用Doug Steele 的代码将它们转换为无 DNS 连接字符串。

于 2009-06-03T03:05:42.893 回答
1

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

于 2009-10-22T22:49:52.670 回答