【サンプル C#】
DataTable 内では一時的にユニークな仮番号を設定するサンプル
//データ取得時
//リレーションの設定
ds.Relations.Add("リレーション名", 親DataColumnオブジェクト, 子DataColumnオブジェクト);
//データ登録時
//ds DataSet
//daParent DataAdapter
//dsChild DataAdapter
//更新
daChild.Update(ds.Tables["子"].Select( null, null, DataViewRowState.ModifiedCurrent));
daParent.Update(ds.Tables["親"].Select(Nothing, Nothing, DataViewRowState.ModifiedCurrent));
//削除
daChild.Update(ds.Tables["子"].Select(Nothing, Nothing, DataViewRowState.Deleted));
daParent.Update(ds.Tables["親"].Select(Nothing, Nothing, DataViewRowState.Deleted));
//追加
daList.Update(ds.Tables["親"].Select(Nothing, Nothing, DataViewRowState.Added));
daParent.Update(ds.Tables["子"].Select(Nothing, Nothing, DataViewRowState.Added));
|