开发者

VB.NET and Program Architecture

开发者 https://www.devze.com 2022-12-11 04:41 出处:网络
I would like to write a program like sales in which there\'s two table to insert i.e: SaleHeader Table and SaleDetails Table.The开发者_JS百科se two tables have (one to many) relationship. When I inser

I would like to write a program like sales in which there's two table to insert i.e: SaleHeader Table and SaleDetails Table. The开发者_JS百科se two tables have (one to many) relationship. When I insert to SaleDetails Table I need to get SaleHeaderID to insert at SaleDetails.

Now I am using a stored procedure to insert SaleHeader information and to get back SaleHeaderID and I use query statements to insert SaleDetail information.

Any one can advise me for more effective way to insert to those two tables (having one to many relationship) ? Help me! Thanks in advance all.


One approach is to use a Guid for the SaleHeaderID. Then you can generate the new id in your stored procedure (using NEWID()) before inserting the header record, and then you will also know the id so you can use it for the details.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号