2009-06-01 67 views
0

這源於之前提出的一個問題 - 關於與表單的寫入衝突,但問題似乎源於我可以更新鏈接表中現有記錄的事實一個系統DSN,而不是另一個DSN(不同數據庫)提供的另一個鏈接表 - 允許我首先輸入記錄,但卻阻止我對記錄進行任何更改,就像另一個用戶更改了我之前的數據一樣。在服務器上沒有爲缺省值定義檢查約束,沒有觸發器,沒有視圖,沒有其他用戶訪問同一個表。不允許對記錄進行更新 - 寫入衝突

這兩個DSN都設置了IDENTICAL,除了它們打開的默認數據庫 - 第一個打開gtdata_test,而第二個DSN打開instkeeper_test。 SQL Server實例上的兩個數據庫都屬於我,我是唯一登錄的用戶。

我已經測試過這個,並且這個問題發生在表級別(在程序中沒有VBA寫入,沒有任何內容)和手動更新。

如果有幫助,我會在好表中包含CREATE語句,並在其下面包含受影響的表。我希望有人能幫助我,因爲我剛剛從創意中走出來。

代碼來創建Supplier_Master表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 

代碼來創建tblSupplierInfo在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 

代碼在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小時 - -

我發現一個奇怪的問題,當使用是/否複選框和SQL Server wi訪問。顯然,Access會將NULL解釋爲否 - 更改該值,但SQL Server不會將NULL解釋爲位域中的否(在轉換中將轉換爲「是/否」),因此當值不是時會引發寫入衝突錯誤必需的,並且是NULL。解決方案是重新設計表格,以便需要一個值,併爲每個以前的Yes/No複選框分配了默認值。這解決了神祕的寫入衝突消息,並允許在創建記錄後對其進行更改。

回答

2

之間存在訪問如何處理是/否複選框值和SQL Server的差異。當翻譯是/從訪問SQL Server不布爾值,你一定要記得定義一個默認的狀態,以及其標記爲需要一個答案。否則,你會得到寫衝突每一次,它會阻止記錄被保存更改,一旦初始值被設置。

1

您是否嘗試過刪除表格鏈接並重新創建它們?對鏈接到的表/視圖所做的更改可能會導致它們變爲只讀,除非將其刪除並重新創建,否則無法進行更正。

而且,我鏈接使用DSN,但隨後用Doug Steele's code to convert them to DNS-less connection strings.

+0

我找到了答案 - 我會注意到它在後上方。感謝您嘗試新的東西,但可悲的是 - 這不是解決方案的一部分。它原來是靠不住的東西與Access如何處理是/與SQL Server時,這些值沒有複選框和空值。 – 2009-06-03 18:05:29

1

我有過類似的「寫入衝突」與Access前端到SQL Server時記錄包含NULL位數據類型列(S),我注意到你的表中包含,即使你不更新這些列。設置位數據類型列缺省值0和更新與空的bit數據類型列現有的記錄爲0,有固定的我。