473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Fastest way to clone a dataset with filter

Hi,

I would like to know the fastest way to clone a dataset with filter inVB.Net
or C#. Say I have a dataset that has one datatable having several data rows.
I want to clone the structure to another dataset but with selection of
datarows.
Please Help!

Nov 19 '05 #1
2 1722
Hope this is the fastest:

Dim theTable as DataTable = theDataSet.Tables(0)
Dim secondTable As DataTable = theTable.Clone()
theTable.DefaultView.RowFilter = "SomeColumn=123" ' If integer
Dim oneRowView As DataRowView
For Each oneRowView In theTable.DefaultView
secondTable.ImportRow(oneRowView.Row)
Next
Dim newDataSet as DataSet = new DataSet
newDataSet.Tables.Add(secondTable)
"Danny Ni" <dn*@yahoo.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Hi,

I would like to know the fastest way to clone a dataset with filter
inVB.Net
or C#. Say I have a dataset that has one datatable having several data
rows.
I want to clone the structure to another dataset but with selection of
datarows.
Please Help!

Nov 19 '05 #2
Hi,

This might be one of the fastest (and shortest code) method to do that.

newDs.Merge(origDs.Tables[0].Select("filterExpression"));

the newDs will be your clone DS that contains the filtered DataRows.

HTH,
"Danny Ni" <dn*@yahoo.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
Hi,

I would like to know the fastest way to clone a dataset with filter
inVB.Net
or C#. Say I have a dataset that has one datatable having several data
rows.
I want to clone the structure to another dataset but with selection of
datarows.
Please Help!

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the...
2
by: Tina | last post by:
what is the easiest way to clone an vs.net aspx project under another name? thanks, T
3
by: Shahriar | last post by:
I am using the following statement to filter a dataset. ds.Tables(0).DefaultView.RowFilter = "ID='" & currentpos & " ' It seems to run fine. My question is since I have a filter set, why is the...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
2
by: UJ | last post by:
I have a dataset that will have say 10000 records in it with the names of files that are used by the system. I then have a large directory of files that correspond to that list of files and want to...
2
by: Anandan | last post by:
Hi, In our Project we use Dataset to load the Grid with Values. We have some criteria to filter the values to be shown in the Grid. For that we used the SELECT command to filter the Same...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.