RE: DataTable.RemoveRow
From: Kevin Yu [MSFT] (v-kevy_at_online.microsoft.com)
Date: 02/10/04
- Next message: Ather Ali Shaikh: "About Debugging"
- Previous message: Miha Markic [MVP C#]: "Re: Compacting and Repairing an Access DB"
- In reply to: JT: "RE: DataTable.RemoveRow"
- Next in thread: JT: "RE: DataTable.RemoveRow"
- Reply: JT: "RE: DataTable.RemoveRow"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 10 Feb 2004 12:20:04 GMT
Hi JT,
I have retried to reproduce the contraint exception according to your
description, but failed. As far as I know, the unique constraint only works
when you are adding rows to the table. It doesn't affect the
DataAdapter.Fill method.
I think the best way to merge the data, is to import rows one by one in a
loop. We can fill the new rows into another DataSet and use
DataTable.ImportRow method to get the rows from the new DataSet. When the
constraint is violate, an ConstraintException is thrown. We can handle the
exception and do nothing in the exception handler. The row will not be
added to the table. After the loop, all valid rows will be added to the
table. Here is an example:
foreach(DataRow dr in dataset2.Table1.Rows)
{
try
{
this.dataSet1.Table1.ImportRow(dr);
}
catch(ConstraintException)
{
}
}
Hope this helps. If this doesn't work, please feel free to let me know. I'm
standing by to be of assistance.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
- Next message: Ather Ali Shaikh: "About Debugging"
- Previous message: Miha Markic [MVP C#]: "Re: Compacting and Repairing an Access DB"
- In reply to: JT: "RE: DataTable.RemoveRow"
- Next in thread: JT: "RE: DataTable.RemoveRow"
- Reply: JT: "RE: DataTable.RemoveRow"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|