tags:

views:

45

answers:

2

I'm doing operation on a dataset containing data from a sql table named Test_1 and then get the updated records using the DataSet.GetChanges(DataRowState.Modified) function. Then i try to save the dataset containing the updated records on a different table than the source one (the table is names Test and has the same structure as Test_1) using the following statement: sqlDataAdapter.Update(changesDataSet,"Test");

I'm getting the following error : Update unable to find TableMapping['Test'] or DataTable 'Test'

I'm new to ado.net and don't even know if it"s something possible. Any advice is welcome.

Just to provide a bit of context. ETL jobs are importing data in temp table with same structure as the original but with _jobid suffix. Right after a rule engine is doing validation before updating the original table.

A: 

why don't you create an update trigger on the table instead that will insert into the other table?

SQLMenace
yes i've also thing about this but i cannot change the database.
John Dev
A: 

if test and test_1 contain are totally equal, this works:

  DataSet1 ds = new DataSet1();
            var da = new DataSet1TableAdapters.DepositTableAdapter();
            var da1 = new DataSet1TableAdapters.Deposit_1TableAdapter();
            da.Fill(ds.Deposit);

            foreach (DataSet1.DepositRow row in ds.Deposit.Rows)
            {
                if (row.ID == 3)
                {
                    row.Amount++;
                }
                foreach (var c in row.ItemArray)
                {
                    Console.Write(c);

                }
                Console.WriteLine("");
            }

            Console.WriteLine(ds.Deposit.GetChanges(System.Data.DataRowState.Modified).Rows);


            var updateTable = new DataSet1.Deposit_1DataTable();

            foreach (DataSet1.DepositRow row in ds.Deposit.GetChanges(System.Data.DataRowState.Modified).Rows)
            {
                updateTable.ImportRow((System.Data.DataRow)row);

            }
            da1.Update(updateTable);

Is test_1 everytime empty after the rule engine worked with it? Do test_1 and test have the totally exact rows in them?

I hope i can provide further help if you answear my questions.

Patrick Säuerl