We use nothing but strongly-typed datasets. These methods work routinely for us, so if you're getting an error, you'll have to post your code.
DataSet ds = new DataSet();
ds.Tables.Add(ds2.Tables[0].Copy());
The same works with datasets.
DataSet ds = new DataSet();
ds = ds2.Copy();
>I'll check it out closer but I don't think it will work since the datasets are typed. The tables are already there I just want to "copy" the data from one typed dataset table to another typed dataset table.
>Currently I do this using foreach row in one table and AddTableNameRow() in the other table. It works, but doesn't look pretty :)
>
>>Wouldn't it be:
>>
>>targetDs.Tables.Add( ...Clone() )
>>
>>Cetin
>>
>>>John,
>>>I get the following compiler error:
>>>
>>>Property or indexer 'System.Data.DataTableCollection.this[string]' cannot be assigned to -- it is read only
>>>
>>>
>>>>Einar:
>>>>
>>>>DataTable ds1.Tables[0] = DataSetds2.Tables[0].Copy() produces a deep copy....(structure and data)
>>>>DataTable ds1.Tables[0] = DataSetds2.Tables[0].Clone() produces a copy of the structure only.
>>>>
>>>>
>>>>>>I have two different datasets: datasetA and datasetB
>>>>>>>
>>>>>>>Both datasets contain the same table SameTable.
>>>>>>>
>>>>>>>How do I copy/duplicate the table from datasetA to datasetB?
>>>>>>>
>>>>>>>This does not work: datasetB.SameTable = datasetA.SameTable
>>>>>>>
>>>>>>>Thanks,
>>>>>>>Einar
>>>>>>
>>>>>>Einar,
>>>>>>
>>>>>>I think that you will have to copy the rows one by one because there are a lot of back links in a DataTable.
>>>>>
>>>>>Hmmm that was not the answer I wanted :) That was the answer I came up with myself :)
>>>>>The reason I posted my questions was to "verify" that there wasn't another way.
>>>>>Thanks for your reply.