如何插入主数据表 [英] How Insert Master-Detail DataTable Row

查看:129
本文介绍了如何插入主数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有2个表:

主表=>列:ID,DetailTable_ID,描述
DetailTable =>列:ID,标题

首先,我想向DetailTable添加一行,然后我想向MasterTable添加一行,这将需要一个新的DetailTable row.ID,该ID为-1.
我想将它们添加到DataSet中而不是DataBase中.

我试过了:

There are 2 Table:

MasterTable => Columns: ID, DetailTable_ID, Description
DetailTable => Columns: ID, Title

First I wanna add a row to DetailTable, then I wanna add a row to MasterTable that it will requires a new DetailTable row.ID which is -1.
I want to add them to DataSet not DataBase.

I''d tried this:

long movieID = long.Parse(this.Movie.SelectedValue.ToString());

Data.VMS.DataSet.MovieGenreRow row = this.VMSDataSet.MovieGenre.NewMovieGenreRow();

row.Movie_ID = movieID;


Data.VMSDataSet.GenreRow genreRow = this.VMSDataSet.Genre.NewGenreRow();

genreRow.Title = this.GenreTitle.Text;
genreRow.Description = this.GenreDescription.Text;

this.VMSDataSet.Genre.Rows.Add(genreRow);

row.Genre_ID = -1;

this.VMSDataSet.MovieGenre.Rows.Add(row);

推荐答案

我更新了到genreRow数据库中,然后检索其ID.
没别的了.
I Update to database just genreRow then retrieve its ID.
There is noway else.


这篇关于如何插入主数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆