c# - Can't insert values into a table, because of false database constraint -


i'm having problem. have oracle database setup 3 tables, first 1 project, second skill , third 1 requiredskill, link between first 2 tables. both primary keys in third table foreign key.

at point in program, create project , save in database. directly after insert 2 values requiredskill table, primary key of skill table , primary key of created project.

i insert data following code:

    oraclecommand cmd = new oraclecommand();     cmd.parameters.add(new oracleparameter("projid", project.projid));     foreach (skill skill in skills)     {         cmd.connection = conn;         cmd.parameters.add(new oracleparameter("skillid", skill.skillid));         cmd.commandtext = "insert requiredskill values(:skillid, :projid)";         try         {             conn.open();             cmd.executenonquery();         }         catch (oracleexception)         {         }                 {             conn.close();         }      } 

as execute the query, oracleexception gets caught , tells me project id (the primary key of project table) not exist, however, breakpoints have verified data in table @ time of execution. have answer this?

your insert statement more robust syntax:

insert requiredskill (skillid, projectid) values ( ...) 

... might have columns in wrong order.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -