不允许更新记录 - 写入冲突

发布于 2024-07-23 01:38:24 字数 9100 浏览 5 评论 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。 任何进一步的更改都会丢失,并且每当在数据表视图中的表中更新数据时,都会出现“写入冲突”对话框。

我正在使用的软件:

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

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

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

This stems from a previous question I asked - about a write conflict with a form, but the problem seems to be originating from the fact that I can update existing records in a linked table provided by one System DSN, but not another linked table provided by another DSN (different database) - allowing me to enter records at first, but then preventing me from making any changes to the records as if another user has changed the data before me. There are no check constraints defined on the server for default values, no triggers, no views, no other users accessing the same table.

Both DSNs are set up IDENTICAL except for the default database they open - the first opening gtdata_test, while the second one opens instkeeper_test. Both databases on the SQL Server instance are owned by me, I am the only logged in user.

I have tested this, and this problem occurs at the table level (no VBA in the program written, nothing) with manual updates.

In case it helps, I will include the CREATE statements for the good table, and for the affected tables below it. I hope someone can help me, as I am fresh out of ideas.

Code to create Supplier_Master table in gtdata_test:

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

Code to create tblSupplierInfo in instkeeper_test:

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

Code to create tblSupplierNote in instkeeper_test:

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

Just to overview - any table I pull into the application I am developing using the first DSN are read/write-able, records can be created, removed, and updated without any problem. With the second DSN, any table I pull into the application can be written to ONCE. Any further changes are lost, and a Write Conflict dialog box appears whenever data is updated in the table in datasheet view.

Software I am using:

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

-- Edited 06/03/2009 @ 1307 hours --

I found out that a strange problem that crops up when using Yes/No checkboxes and SQL Server with Access. Apparently, Access will interpret NULL as No - changing the value, but SQL Server will not interpret NULL as a No in a Bit field (what Yes/No gets turned into in conversion) so it throws a Write Conflict error when a value is not required, and is NULL. The solution was to redesign the table so that a value was required, and that there was a default value assigned for EVERY former Yes/No checkbox. This solved the mysterious Write Conflict messages, and allowed changes to records once they were created.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走走停停 2024-07-30 01:38:24

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

There is a difference between how Access handles Yes/No checkbox values and SQL Server. When translating Yes/No booleans from Access to SQL Server, you must remember to define a default state as well as mark it as requiring an answer. Otherwise, you will get write conflicts every time, and it will prevent the record from being saved with your changes once the initial values have been set.

没有伤那来痛 2024-07-30 01:38:24

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

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

Have you tried deleting your table links and recreating them? Changes to the tables/views that you are linking to can cause them to become read-only and there's no way to correct it except to delete them and recreate them.

Also, I link using the DSN, but then use Doug Steele's code to convert them to DNS-less connection strings.

黄昏下泛黄的笔记 2024-07-30 01:38:24

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

I've had similar "Write Conflict" with Access front-end to SQL Server when records contain NULL bit datatype column(s), which I notice your table contains, even if you're not updating those columns. Setting bit datatype columns to default of 0 and updating existing records with bit datatype columns of NULL to 0 has fixed for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文