开发者

How to create a master detail insert form

开发者 https://www.devze.com 2022-12-11 22:42 出处:网络
i\'m using the Northwind database and I want to create a C# .Net Framework windows form to generate an order input.

i'm using the Northwind database and I want to create a C# .Net Framework windows form to generate an order input.

I already linked the tables in my dataset and the binding source and used the binding navigator to be able to view each one of them

The thing is i'm unable to find a way to add the order details to an uncreated order because it throws an exception of inserting null values to the DB. (I thought that using autoincrement will solv开发者_运维知识库e it, but it won't)

do you guys have any idea?


You need to modify the queries created in the dataset.

Open the dataset designer and select the table adapter (The bottom half of the DataTable/TableAdapter pair just above the line that reads Fill,GetData()).

Right click and select Properties.

In the properties pane you see the queries for SELECT, INSERT, UPDATE, DELETE.

Identitfy fields need to be omitted from the INSERT queries. In the update query they need to be used in the where clause to locate the original record to update and excluded from the set portion of the query.

Other fields that need to be supplied (but you don't want entered by the user) can be manually populated in the INSERT query with appropriate data (NEWID() for guids, or GETDATE() for date time fields, etc).

Fields that are calculated should be excluded from both the insert and update queries.

Lastly, fields that wont be changed by an edit operation can be excluded from the set operation of the update query.

0

精彩评论

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

关注公众号