General information
Category:
The Mere Mortals .NET Framework
I am attempting to create a duplicate row in a SQL table. The table has a primary key, so I get an error if I just copy the row back into the same table. I'm using an intermediate business object so I can change the Primary Key before I save the data. Unfortunately, it isn't working.
POs oPO = new POs(); // MM Business Object
POs oPONew = new POs(); //
// Code to retrieve record in oPO
// Works fine, data is inserted into oPONew table[0]
oPONew.DataSet.Tables[0].ImportRow(oPO.DataRow);
// When I check oPONew.DataSet.Tables[0].Rows[0], it has the correct data]
// This line does not set the entity of oPONew. It remains empty and .DataRow = null
oPONew.Entity.SetDataRow(oPONew.DataSet.Tables[0].Rows[0]);
I looked through the MM code, and according to the documentation, the .DataRow property is set to the first row in the data returned from the query (no mention of it changing). However, when I followed the code for the Entity, the Get uses the DataRow property. It doesn't seem to be set. I was under the impression that using the .SetDataRow() would also change the DataRow property, but in .SetDataRow() it's only changing Row in the business entity.
Obviously I'm missing something here.
Thanks for the help,
Jeff Corder
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only