开发者

Foregin key constraint error but shouldn't be occuring

I have a list table with 5 entries in it, the first column in the identity column (PK), within a parent table is a column that is related to this list table by ID (FK). I am using C# in a web app to run an ExecuteScalar with a stored procedure to insert the items into the parent table.

This is within a SQL database

LIST TABLE:

ID INT (PK),
SKILL_SET_NAME VARCHAR

PARENT TABLE:

ID INT,
SKILL_SET_ID INT (FK)

ITEMS WITHIN LIST TABLE:

1, SOMETHING
2, ANOTHER
3, ELSE

INSERT STATEMENT INTO PARENT TABLE

INSERT INTO PARENT TABLE
(ID, SKILL_SET_ID)
VALUES
([NUMBER], 1)

ACTUAL CODE (changed the ExecuteScalar to NonQuery, and the SkillSetID is the foreign key)

public static void SetRIPSSkillSetDetails(int HDR_ID, int SkillSetID, string SkillSetOptional, int SkillSetRating)
{
    ArrayList al = new ArrayList();

    al.Add(new DictionaryEntry("@HDR_ID", HDR_ID));
    al.Add(new DictionaryEntry("开发者_运维百科@SKILL_SET_ID", SkillSetID));
    al.Add(new DictionaryEntry("@SKILL_SET_OPTIONAL", SkillSetOptional));
    al.Add(new DictionaryEntry("@SKILL_SET_RATING", SkillSetRating));

    Core.RunNonQuery("web", "[IPAM_GLOBAL_INSERT_PARTICIPANT_RATING_DTL]", al);

When the code runs the ExecuteScalar I get the Foreign key constraint error, Please help


The stored procedure was bombing out, someone said you can step through sql storec procedures from VS, how do I do that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜