0

我有这些表:

TABLE_DIRECTOR
-directorID
-name
-adres
-birthDate
-yearsExperience

TABLE_FILM
-filmID
-directorID
-filmstudioID
-title
-budget
-filmstudioName
-directorName

TABLE_FILMSTUDIO
-filmstudioID
-name
-website
-foundingDate
-numberOfBuildings

我要做的是detailsview用所有filmdirectors. 我也有一个gridview里面装满了所有工作过filmstudiodirectors东西。

为了填补这一点gridview,我将以下代码放入我的TABLE_FLMSTUDIO_TABLEADAPTER

SELECT TABLE_FILMSTUDIO.filmstudioID, TABLE_FILMSTUDIO.name,
  TABLE_FILMSTUDIO.website, TABLE_FILMSTUDIO.foundingDate,
  TABLE_FILMSTUDIO.numberOfBuildings
FROM TABLE_FILMSTUDIO INNER JOIN
  TABLE_FILM ON TABLE_FILMSTUDIO.filmstudioID = TABLE_FILM.filmstudioID
WHERE (TABLE_FILM.directorID = @directorID)

但是,当我运行页面时,这给了我以下错误

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

有人有想法吗?

4

1 回答 1

1

第一件事:TABLE_FILM -filmID -directorID -title -budget -filmstudioName -directorName 不包含filmstudioID,但您在INNER JOIN 中使用它作为TABLE_FILM.filmstudioID。

其次,错误表明您的一个表包含重复数据。(违反外键)

于 2012-08-16T20:23:06.370 回答