views:

121

answers:

2

Hello,

I use Visual Studio 2010

I have a DataSet with 2 tables

one (MainList) has type, name, path, parameter the other (UpadteList) has path, hash, date

I added files to this list and it work with out problem, now I have the following

when I add file type "update" it will be "Update","My Program", "PATH-TO-/my.setup.exe","/minimized"

if it was type "Update" the following data goes to (UpdateList) "PATH-TO-/my.setup.exe","asdfwefwfgg3r34t34t34t","2010-09-01"

I want when a row in the (MainList) deleted and a row with the same path in (UpdateList) exsist it will deleted too

should I use loop or (I saw) in dataSet properties use Relations

what is the best approach ?

with loops I got into some ugly bugs that delete everything in the Mainlist!

note: I use XML to store data (the data is not big)

A: 

I think that code is arguably the wrong place to deal with data consistency. I'd do it in the database, either in a stored procedure or, if you're using SQL Server, possibly with cascading deletes.

48klocs
I use XML to store data (the data is not big)
Data-Base
+1  A: 

IMO, you have two choices

  1. Use DataTable constraints such as ForeignKeyConstraint with DeleteRule=Cascade settings.
  2. Use RowDeleted/RowDeleting event on MainList data-table to look up and delete the corresponding row in other table.
VinayC