1

I have been trying to create a copy of an object but it appears to be linked in some way. Here is an example

Dim dataview as DataView = results.DefaultView

' Some amazing foreach loop
' but thoughtout the loop I want to create a copy of the data and then filter it

Dim filterView as DataView = dataview
filterView.RowFilter = "County = '" & loop.County &"'"

The plan is to then loop through this subset of data but when I debug the project the data contained within dataview is the same as filterView. I have tried DirectCast() and still get the same result. How do I create a copy of the object without creating some link to the original object?

Hope this makes sense but let me know if you need any further clarification.

1 Answer 1

2

Use Clone method to copy the table structure (Schema). Use the ImportRow method to copy from table to its clone. OR You can use the Copy method of a DataTable object to copy the entire DataTable: OR Copy from the results of a DataView.

http://support.microsoft.com/kb/308909

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I ended up using .Copy() as I couldn't be bothered to copy the data in!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.