-Changed the question into a different simpler form-
Please review this piece of code :
"Given Error" Error :
Update unable to find TableMapping['Table'] or DataTable 'Table'.
The DataSet is Strongly typed, We have a DataTable "dtNew" [Made from a list "ListProducts", (No matter here !)]
one column's name in the database differs from the list's field : "Title" should mapped with the column : "TitleInDb"
SqlCeDataAdapter Adapter;
DsProducts Ds1Products ; // Strongly Typed
DataTable dtNew = new DataTable("Products");
DataColumn dc;
DataRow[] updRows;
// Fields : Name , Title, Price
dc = new DataColumn("Name", typeof(string));
dtNew.Columns.Add(dc);
dc = new DataColumn("TitleInDb", typeof(string)); // The difference is by a reason
dtNew.Columns.Add(dc);
dc = new DataColumn("Price", typeof(string));
dtNew.Columns.Add(dc);
dtNew = updRows.CopyToDataTable();
Ds1Products.Tables.Add(dtNew);
// The Problems appear here :
// The Iteration is just for debugging phase and watching the changes which the columns are same
as before
foreach (var col in dtNew.Columns)
{
Console.WriteLine(col.ToString());
Console.WriteLine(col.GetType());
}
// New Table is there, But here will come the Error
Adapter.Update(Ds1Products);
Running this, Iterating through the new columns I see that there is no change to the "Products" table which I thought should have been deleted at that time. Also the name of the new table "dtNew"
seems to be "table1"
Additional Notes : It uses Sql Compact 3.5 The code is just a piece of code, Showing the exact problem !
please review the code and give your ideas on this, I'm trying to make the whole database based on a refreshed Table (or DataRows[] )
Edit : *Replace a DataTable in a DataSet :* It means remove the first DataTable and Create new one and place it in ! Couldn't say easier ... (Based on a comment)