Re: Removing duplicate records
From: Peter (czupet_at_wsinc.com)
Date: 03/12/04
- Next message: Paul Clement: "Re: OleDbParameter"
- Previous message: Vance Kessler: "Re: How do you save a single DataRow in a DataSet?"
- In reply to: Kevin Yu [MSFT]: "RE: Removing duplicate records"
- Next in thread: Kevin Yu [MSFT]: "Re: Removing duplicate records"
- Reply: Kevin Yu [MSFT]: "Re: Removing duplicate records"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 12 Mar 2004 07:44:31 -0600
What is the syntax for the filter?
I want to select only one record
ds.Merge(dsXml.Tables[0].Select("Only first record"));
Thanks
"Kevin Yu [MSFT]" <v-kevy@online.microsoft.com> wrote in message
news:k8$OrRBCEHA.2304@cpmsftngxa06.phx.gbl...
> Hi Peter,
>
> Thank you for posting in the community!
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need to merge the DataSets from
the
> Xml files into one and you need to remove the duplicate rows. If there is
> any misunderstanding, please feel free to let me know.
>
> As far as I know, to remove the duplicate records, we need add a primary
> key to the table. The primary key is for the table to identify a row and
to
> decide whether two records are the same. When merging two DataSets with
> primary key, the method will automatically overwrite the old record with
> new fetched one. So that only one copy of that record will be added.
>
> If there is no primary key set in the table, I think we have to write more
> code to achieve this. We can use the Select method to decide whether the
> records exists in the current DataSet. Here I have made some changes to
> your code.
>
> DataSet ds = new DataSet();
> DataSet dsXml = new DataSet();
>
> try
> {
> string [] files = Directory.GetFiles(path,"VisitTable_*.xml");
> foreach(string file in files)
> {
> dsXml.ReadXml(file, System.Data.XmlReadMode.Auto);
> foreach(DataRow dr in dsXml.Tables[0].Rows)
> {
> if(ds.Tables[0].Select("Filter expression here to decide whether the
> records exists.").Length == 0)
> ds.Tables[0].Rows.Add(dr.ItemArray);
> }
> }
> }
> catch(Exception e)
> {
> throw e;
> }
>
> HTH. If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
- Next message: Paul Clement: "Re: OleDbParameter"
- Previous message: Vance Kessler: "Re: How do you save a single DataRow in a DataSet?"
- In reply to: Kevin Yu [MSFT]: "RE: Removing duplicate records"
- Next in thread: Kevin Yu [MSFT]: "Re: Removing duplicate records"
- Reply: Kevin Yu [MSFT]: "Re: Removing duplicate records"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|