G
Guest
Hi Everybody
I have a Problem getting Data out of a View...I always get: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. " I have no Idea what the error might be...
my view:
SELECT DISTINCT
dbo.tb_Verkaeufer.ver_Nummer, dbo.tb_Verkaeufer.ver_GueltigBis, dbo.tb_Verkaeufer.ver_AenderungDurch, dbo.tb_Verkaeufer.ver_Name1,
dbo.tb_Verkaeufer.ver_Postfach, dbo.tb_Verkaeufer.ver_Zusatzangaben, dbo.tb_Verkaeufer.ver_Strasse, dbo.tb_Verkaeufer.ver_PLZ,
dbo.tb_Verkaeufer.ver_Ort, dbo.tb_Verkaeufer.ver_Kurzname, dbo.tb_RepositoryCodes.rec_Beschreibung, dbo.tb_Verkaeufer.ver_Telefon,
dbo.tb_Verkaeufer.ver_Fax, dbo.tb_Verkaeufer.ver_Email, dbo.tb_Verkaeufer.ver_Sperrcode, dbo.tb_Verkaeufer.ver_ProvisionDirekt,
dbo.tb_RepositoryCodes.rec_Sprache
FROM dbo.tb_Verkaeufer LEFT OUTER JOIN
dbo.tb_RepositoryCodes ON dbo.tb_Verkaeufer.ver_Sprachcode = dbo.tb_RepositoryCodes.rec_Code
WHERE (dbo.tb_RepositoryCodes.rec_ObjektTyp = 'tb_Verkaeufer') AND (dbo.tb_RepositoryCodes.rec_Spaltenname = 'knd_Sprachcode')
this view gets some rows and every row is in there 3 times with a different languageID called "rec_Sprache". I now want to specifiy the select command when i execute the qury out of ado.net. my code looks as follwo:
....
daVerkaeuferDetailsAll.SelectCommand.CommandText += @" WHERE ver_Nummer = @VER_Nummer AND ver_GueltigBis = @VER_GueltigBis AND rec_Sprache = @SprachID";
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@VER_Nummer",ver_Nummer);
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@VER_GueltigBis",ver_GueltigBis);
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@SprachID",sprachID);
daVerkaeuferDetailsAll.Fill(dt);
....
what am i doing wrong... If i copy the qury string out of the selectcommand object after it is created an i let it run in the query analyzer...it returns exactly one row with the right languageid...
thanks for your help
Plunaldo
I have a Problem getting Data out of a View...I always get: "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints. " I have no Idea what the error might be...
my view:
SELECT DISTINCT
dbo.tb_Verkaeufer.ver_Nummer, dbo.tb_Verkaeufer.ver_GueltigBis, dbo.tb_Verkaeufer.ver_AenderungDurch, dbo.tb_Verkaeufer.ver_Name1,
dbo.tb_Verkaeufer.ver_Postfach, dbo.tb_Verkaeufer.ver_Zusatzangaben, dbo.tb_Verkaeufer.ver_Strasse, dbo.tb_Verkaeufer.ver_PLZ,
dbo.tb_Verkaeufer.ver_Ort, dbo.tb_Verkaeufer.ver_Kurzname, dbo.tb_RepositoryCodes.rec_Beschreibung, dbo.tb_Verkaeufer.ver_Telefon,
dbo.tb_Verkaeufer.ver_Fax, dbo.tb_Verkaeufer.ver_Email, dbo.tb_Verkaeufer.ver_Sperrcode, dbo.tb_Verkaeufer.ver_ProvisionDirekt,
dbo.tb_RepositoryCodes.rec_Sprache
FROM dbo.tb_Verkaeufer LEFT OUTER JOIN
dbo.tb_RepositoryCodes ON dbo.tb_Verkaeufer.ver_Sprachcode = dbo.tb_RepositoryCodes.rec_Code
WHERE (dbo.tb_RepositoryCodes.rec_ObjektTyp = 'tb_Verkaeufer') AND (dbo.tb_RepositoryCodes.rec_Spaltenname = 'knd_Sprachcode')
this view gets some rows and every row is in there 3 times with a different languageID called "rec_Sprache". I now want to specifiy the select command when i execute the qury out of ado.net. my code looks as follwo:
....
daVerkaeuferDetailsAll.SelectCommand.CommandText += @" WHERE ver_Nummer = @VER_Nummer AND ver_GueltigBis = @VER_GueltigBis AND rec_Sprache = @SprachID";
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@VER_Nummer",ver_Nummer);
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@VER_GueltigBis",ver_GueltigBis);
daVerkaeuferDetailsAll.SelectCommand.Parameters.Add("@SprachID",sprachID);
daVerkaeuferDetailsAll.Fill(dt);
....
what am i doing wrong... If i copy the qury string out of the selectcommand object after it is created an i let it run in the query analyzer...it returns exactly one row with the right languageid...
thanks for your help
Plunaldo