WinForm中DbDataAdapter.Update()方法出现莫名其妙的System.ArgumentOutOfRangeException异常[UP有分]
数据表结构
person_table1:
person_no
1
2
...
phone_table1:
phone_no phone person_no
1 13800000001 2
2 13800000002 3
3 13800000003 1
...
主表person_table1与从表phone_table1通过person_no相关联
数据库连接及数据集的填充都正常,数据集中包含关系以及主键信息。
person_table1的视图在界面上与TextBox类型的控件绑定,phone_table1的视图与DataGrid绑定。
DataView dataView_Person1 = new DataView(tablePerson1, "", "",
DataViewRowState.CurrentRows);
// rel_PersonTPhone1为主从表之间的relation
DataView dataView_Phone1 = dataView_Person1[0].CreateChildView(rel_PersonTPhone1);
// 在实际程序中dataView_Phone1的数据会根据dataView_Person1的导航而改变
this.BindingContext[dataView_Phone1].EndCurrentEdit();
if (ds_Db1.HasChanges())
{
System.Data.DataSet ds_Changes = ds_Db1.GetChanges();
//在这步出现异常!
adapter_Phone1.Update(ds_Changes, "phone_table1");
}
异常信息:{"索引超出范围。必须为非负值并小于集合大小。\r\n参数名: index" }
Type: System.ArgumentOutOfRangeException
HResult: -2146233086
Source: "System.Data"
.NET FrameWord:1.1
数据库:Firebird1.5
数据访问驱动:Firebird .NET Provider1.5.2-NET1.1