PastorDwayne
asked on
NewRow to DataSet
Good-day,
I have a dataset containing two tables, in a Master-Detail type relationship. I would like to insert a new row into the child table, but I'm receiving an error "ForeignKeyConstraint RelTables requires the child key values (There) to exist in the parent table".
Here is my code:
************************** ********** ******
//DataSet ds
DataRelation relate;
relate = new DataRelation("RelTables", ds.Tables["Parent"].Column s["Col1"], ds.Tables["Child"].Columns ["Col1"]);
ds.Relations.Add(relate);
DataRow dr;
dr = Form1.DVM.DataSet.Tables[" Child"].Ne wRow();
dr["Col1"] = "Hello";
dr["Col2"] = "World";
ds.Tables["Child"].Rows.Ad d(dr);
************************** ********** ******
Any suggestions would be appreciated,
Thanks for your time.
I have a dataset containing two tables, in a Master-Detail type relationship. I would like to insert a new row into the child table, but I'm receiving an error "ForeignKeyConstraint RelTables requires the child key values (There) to exist in the parent table".
Here is my code:
**************************
//DataSet ds
DataRelation relate;
relate = new DataRelation("RelTables", ds.Tables["Parent"].Column
ds.Relations.Add(relate);
DataRow dr;
dr = Form1.DVM.DataSet.Tables["
dr["Col1"] = "Hello";
dr["Col2"] = "World";
ds.Tables["Child"].Rows.Ad
**************************
Any suggestions would be appreciated,
Thanks for your time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you need to call SetParentRow