MattyG
MattyG

Reputation: 8497

How can I copy all TableAdapters from one DataSet to another DataSet?

I have a DataSet (DataSet1) with many tables and about 80 custom TableAdapters in my C# project. I have DataSet2 with the same tables and structure as DataSet1. In the DataSet Editor I want to be able to copy all the custom table adapters from DataSet1 to DataSet2. I could open the .xsd in the XML editor and attempt to edit that manually, but it will get messy with 80+ TableAdapters.

Why am I doing this? Because my DataSet1 is broken (big issue, similar to the one discussed here and here), so I'm recreating it from scratch. I need a fast way of adding the 80 TableAdapters into the new DataSet.

Upvotes: 1

Views: 2913

Answers (2)

MattyG
MattyG

Reputation: 8497

As Tim has suggested, it looks like bulk copying of the TableAdapters can only be done by copying the tables and TableAdapters together.

For interest sake, the process to fix the corrupted .xsd DataSet / Connection string issue was:

  • Create a new DataSet.
  • Configure the new DataSet to use the existing connection string to pull tables from the DB
  • Delete these tables from this new DataSet, leave it blank
  • Select All and Copy from the old DataSet (all tables, TableAdapters, relationships)
  • Paste into the new DataSet

This process leaves you with a good connection string (and non-corrupted .xsd file) for the new dataset, and maintains all the custom TableAdapters that were originally created in the first DataSet.

Upvotes: 0

Tim Schmelter
Tim Schmelter

Reputation: 460158

Have you tried to simply copy & paste all?

Press Ctrl+A, then Ctrl+C and finally Ctrl+V in the designer of the second DataSet.

That should work normally.

Upvotes: 1

Related Questions