C# TableAdapter 不插入和更新

C# TableAdapter doesn't insert and update

我有一个名为 DB.mdf 的数据库,在我的程序中,我使用此代码在此数据库中插入一个新行:

DBDataSet ds = new DBDataSet();
DBDataSetTableAdapters.IPTableAdapter ipadap = new DBDataSetTableAdapters.IPTableAdapter();

ipadap.InsertQuery(ip);

插入查询是:INSERT INTO [IP] ([ID], [indirizzo]) VALUES (0, @indirizzo);

程序执行所有步骤,但不在数据库中插入行。为什么?

更新 现在我试过这段代码:

DBDataset.IPRow newRegionRow;
newRegionRow = db.IP.NewIPRow();
newRegionRow.ID = "6";
newRegionRow.indirizzo = "NorthWestern";
// Add the row to the Region table
this.db.IP.Rows.Add(newRegionRow);
// Save the new row to the database
this.ipadap.Update(this.db.IP);

并且在这种情况下不在数据库中写入新行

我发现错误了!!!我不知道 Visual Studio,在开发期间,在 /bin 中创建一个数据库副本,它与数据库副本一起工作。

感谢大家。

https://msdn.microsoft.com/en-us/library/ms246989.aspx