Re: Removing rows from two connected tables

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Mar 13, 9:12 pm, "mick" <coughco...@xxxxxxxxxxx> wrote:
I have two tables Game and Disks

Game-
 GameID     (PrimaryKey)
 GameName
 ...

Disks
 DiskID
 ...
 GameID    (ForeignKey)

On my Form I have a listbox that shows the GameName field for each row.
When the Remove_button is pressed the selected listbox item is removed
from both the Game and Disk tables. The problem was, however when  I
hit the

    gameTableAdapter.Update(gamesArchiveDataSet);

I got the following error-

The DELETE statement conflicted with the REFERENCE constraint
"FK_Disks_Game". The conflict occurred in database
"C:\USERS\MICK\DOCUMENTS\VISUAL STUDIO 2008\PROJECTS\GAME ARCHIVES\GAME
ARCHIVES\BIN\DEBUG\GAMESARCHIVE.MDF", table "dbo.Disks", column 'GameID'.

The thing is, when I commented out this line and just did the Update() on
the "Disk" table it worked and the rows
from _both_ of the tables were removed from the Dbase. I`m pleased that it
works but I was wondering if
someone could give a little explanation why it works and why the updating of
the gameTableAdapter fails.

Most likely, when you do the Update() on games, it tries to delete
record from Games table first, and only then those from Disks. If you
have any records in Disks referencing the one you're trying to delete
from Games, then deletion would result in a foreign key constraint
violation (since you would get a bunch of Disks that reference a non-
existing Game).
.



Relevant Pages

  • Re: Any raw data specs for the Apple IIgs BRAM?
    ... settings I want to be one way for II games and another way for the ... control panel or choices at all. ... click among a choice of six mounts all your disks. ... I guess I've become too accustomed to real machines and most emulators, ...
    (comp.sys.apple2.programmer)
  • Re: ebay australia IIgs collection -> $69,000!
    ... drive, stereo card and speakers, floppy drives, and plenty of games ... vague statements like "A number of heavily & custom built Apple IIGS ... disks, manuals, or anything else sold for $86 AUD. ... Old Apple][games and disks are also going for crazy prices, ...
    (comp.sys.apple2)
  • Re: ebay australia IIgs collection -> $69,000!
    ... drive, stereo card and speakers, floppy drives, and plenty of games ... vague statements like "A number of heavily & custom built Apple IIGS ... disks, manuals, or anything else sold for $86 AUD. ... Old Apple][games and disks are also going for crazy prices, ...
    (comp.sys.apple2)
  • Re: Gothic Universe
    ... And, because these titles are on DVD, once you install them, you won't need ... to insert the disks again. ... The Total War Era games are old enough that they get along with the ...
    (comp.sys.ibm.pc.games.rpg)
  • Re: ebay australia IIgs collection -> $69,000!
    ... drive, stereo card and speakers, floppy drives, and plenty of games ... vague statements like "A number of heavily & custom built Apple IIGS ... disks, manuals, or anything else sold for $86 AUD. ... Old Apple][games and disks are also going for crazy prices, ...
    (comp.sys.apple2)