我在通过使用 DataAdapter 写回我的 Access 数据库 (.accdb) 时遇到问题。
目前,我有一个 Fill 方法,它用数据填充 DataSet 表。这段代码目前位于我的 Form_Load() 中。
// TODO: This line of code loads data into the 'hCAliasDataSet.Topics' table. You can move, or remove it, as needed.
this.topicsTableAdapter.Fill(this.hCAliasDataSet.Topics);
然后我有一个 cmdAdd_Click() 事件,这显然是在 hCAliasDataSet 中的 Topcis 表中添加一个新行。
// Create a new row, append it to Topics table.
DataRow DR;
DR = this.hCAliasDataSet.Tables["Topics"].NewRow();
this.hCAliasDataSet.Tables["Topics"].Rows.Add(DR);
接下来,我创建了一些代码来捕获其中一个列值的输入。
// Capture user input
sTopicName = Interaction.InputBox("Please Enter Topic Name", "Topic Name", null, 100, 100);
// Set the Topic value for the new Row
DR["Topic"] = sTopicName;
我的问题,我假设在这里,我调用 dataAdapter 来更新主题表。我手动检查数据库,并没有创建任何新行?
// Commit the changes back to the hCAlias DataBase (hcalias.accdb).
this.topicsTableAdapter.Update(this.hCAliasDataSet.Topics);
编辑:我相信我需要为我的 TableAdapter 创建一个 INSERT 查询,这是否正确?