views:

68

answers:

1

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

A: 

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

mattgcon