problem in loaddatarow
i am facing a problem while updating a particular row in datatable by using loaddatarow.
i am giving the structure of the datatable
DataTable temp= new DataTable();
DataColumn pkCol = temp.Columns.Add("PCOD", typeof(String));
temp.Columns.Add("PDES", typeof(String));
temp.PrimaryKey = new DataColumn[] {pkCol};
for( int i=0;i<5;i++)
{
DataRow myrow;
myrow = temp.NewRow();
myrow["PCOD"] = i
myrow["PDES"] = "";
temp.Rows.Add(myrow);
//now i am updating this datatable with loaddatarow for a test
object[] newRow = new object[2];
newRow[0] = i;
newRow[1] = "abcgd"
DataRow myRow;
temp.BeginLoadData();
myRow = temp.LoadDataRow(newRow, false);
temp.EndLoadData();
}
it is giving me an error on the line "temp.endloaddata",
"Unable to enable the constraint"
the only constraint here is primary key. i am unable to figure out why the method is unable to update the row.
any pointers to this will be of great help.
Note:--i tried even changing the 2nd parameter to "true " but of no use
regards
rahul pokharna
__________________
regards
rahul pokharna
|