DataSet not updating Database

277 Views Asked by At

I have a dataset with about 6 rows. I can confirm the dataset's table is filled by getting its row count. I fill the dataset with rows from a previously filled dataset from a different source. According to all the articles I've found here and on the internet in general, I'm supposed to call dataset.datatable.AcceptChanges() then tableadapter.Update(dataset.datatable), but the new data is never recorded on the new database. This is what I'm doing:

using FbConnection originalDB = new FbConnection($@"data source=localhost;initial catalog={AppDomain.CurrentDomain.BaseDirectory}OLD_DATABASE.FDB;user id=SYSDBA;password=masterkey");
using FbConnection destinationDB = new FbConnection($@"data source=localhost;initial catalog={AppDomain.CurrentDomain.BaseDirectory}NEW_DATABASE.FDB;user id=SYSDBA;password=masterkey");

var originalset = new DataSet1();
var destinationset = new DataSet1();

var groupsTableAdapter = new DataSet1TableAdapters.GroupsTableAdapter() { Connection = originalDB };

groupsTableAdapter .Fill(originalset.GroupsTable);

groupsTableAdapter= new DataSet1TableAdapters.GroupsTableAdapter() { Connection = destinationDB };

foreach (DataSet1.GroupsRow groupRow in originalset.GroupsTable.Rows)
{ 
            destinationset.GroupsTable.ImportRow(groupRow);
            Console.WriteLine($"ROW PROCESSED> {groupRow.GroupID}");
}
int rows = destinationset.GroupsTable.Rows.Count;
Console.WriteLine(rows + " added");
destinationset.GroupTable.AcceptChanges();
GroupsTableAdapter.Update(destinationset.GroupsTable);

When I check the database with a third-party software, the table is empty. What am I doing wrong here?

0

There are 0 best solutions below