B
Ben Bloom
I keep getting
System.SystemException {"ForeignKeyConstraint
SecuritySecurity_Cross_Reference requires the child key values
(0c6cbf28-790f-494c-b05c-64e70521d18600) to exist in the parent table."
when I try to insert a row in a child table. It happens when I create
the row, which has me a little confused. Here's my code:
....
DataRow drSec = ds.Tables["Security"].NewRow();
drSec["Security_ID"] = System.Guid.NewGuid() + i.ToString();
//Set a bunch of values in the table
ds.Tables["Security"].Rows.Add(drSec);
DataRow dr;
dr = ds.Tables["BlockTrade"].NewRow(); <-- error here.
dr.SetParentRow(drSec);
dr["Security_Id"] = ds.Tables["Security"].Rows[0]["Security_Id"];
....
What am I doing wrong?
Thanks.
System.SystemException {"ForeignKeyConstraint
SecuritySecurity_Cross_Reference requires the child key values
(0c6cbf28-790f-494c-b05c-64e70521d18600) to exist in the parent table."
when I try to insert a row in a child table. It happens when I create
the row, which has me a little confused. Here's my code:
....
DataRow drSec = ds.Tables["Security"].NewRow();
drSec["Security_ID"] = System.Guid.NewGuid() + i.ToString();
//Set a bunch of values in the table
ds.Tables["Security"].Rows.Add(drSec);
DataRow dr;
dr = ds.Tables["BlockTrade"].NewRow(); <-- error here.
dr.SetParentRow(drSec);
dr["Security_Id"] = ds.Tables["Security"].Rows[0]["Security_Id"];
....
What am I doing wrong?
Thanks.