0

我有一个大约 6 行的数据集。我可以通过获取其行数来确认数据集的表是否已填充。我用来自不同来源的先前填充数据集的行填充数据集。根据我在这里和互联网上找到的所有文章,我应该打电话dataset.datatable.AcceptChanges()then tableadapter.Update(dataset.datatable),但新数据从未记录在新数据库中。这就是我正在做的事情:

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);

当我用第三方软件检查数据库时,表是空的。我在这里做错了什么?

4

0 回答 0