2012-06-05 58 views
0

我是ASP.NET的新手,所以這個問題可能聽起來很愚蠢,但我真的需要幫助。我得到的錯誤:刪除數據集的約束條件

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

因此,我決定選擇Visual Studio建議的快速方式:在我的數據集中約束的轉向。從我在網上查到,該解決方案是增加photoDataTable.EnforceConstraints = false;但後來我得到另一個錯誤:

'PhotoDataSet.PhotosDataTable' does not contain a definition for 'EnforceConstraints' and no extension method 'EnforceConstraints' accepting a first argument of type 'PhotoDataSet.PhotosDataTable' could be found (are you missing a using directive or an assembly reference?)

我想知道如果我需要包括任何「使用」,如果是這樣,我應該包括哪些內容?否則,我該怎麼辦?請幫忙。

+0

'DataTable'和'DataSet'是不同的東西。設置'DataSet'的['EnforceConstraints'屬性](http://msdn.microsoft.com/en-us/library/system.data.dataset.enforceconstraints.aspx)。 –

回答

2

EnforceConstraintsDataSet的財產,而不是DataTable

+0

謝謝。其實我只在我的代碼中使用DataTable,所以我不知道如何解決這個問題。 –

+0

可能您違反了本地表約束,而不是外鍵。 – Ruben

+0

這很奇怪,因爲我沒有任何約束或外鍵。 –