Master / Detail form generates FK error upon save when both master and details contains new records

Posted on 2008-11-18
Last Modified: 2012-05-05
I'm having a typical OrderForm with Order details in a datagridview like in the Northwind DB.

I create a dataset containing Order and Orderdetails.

I drag detils from Order and a gridviw from orderdetails under order.

When I run it, it works fine until I create a new order and enters order details. The temporary orderno -1 creates a foreign key error in orderdetails when I save. I thought the table adapter would take care of this for me?

Any suggestions?

Question by:ekenman
    1 Comment

    Accepted Solution

    OK, I've got it. I've been sitting with this issue for two days and just becase I entered the question I found the solution.

    In the Dataset Designer, right click the relation and choose Edit Relation.

    Change the relation from Relation Only to Both Relation and Foreign Key Contraint.

    Choose Update Rule to Cascade.

    Now it works!

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now