How do I set up a cascade delete?


  • Hi all,

    This is for Visual Studio 2010 and SQL Server Compact 3.5

    I have two tables: stockNames and stockData. StockName has only one column. stockData has several columns with one of them being the same column as in stockNames. I'm using the single column stockNames to quickly read and update a listbox on my form.

    I want to be able to erase a stockName entry and automatically delete all of its entries in the stockData table. I read that I need to create a relationship but when I got to the screen to do it ... I got lost. There is "update rule", "delete rule" with 3 options in each. I found a page that seems to explain every entry but ... I guess I'm a bit slow :-) ... I did not understand how to set up a cascade delete. Could someone point me in the right direction please?

    Here is what the data looks like (dummy data shown). If I delete TSM from stockNames the 3 entries in stockData should be deleted as well:

    stockNames table: column name: stock:





    stockData table: column names: ask, bid, volume, date, time, stock, delta, hi, lo

    12.50 12.75 2500 6/22/2013 12:25pm TSM 0.5265 13.00 10.58

    12.55 12.65 5600 6/20/2013 13:22pm TSM 0.5265 13.00 10.58

    12.00 12.05 8800 6/12/2013 15:44pm TSM 0.5265 13.00 10.58

    12.50 12.75 2500 6/22/2013 12:25pm F 0.5265 13.00 10.58

    12.50 12.75 2500 6/22/2013 12:25pm AAPL 0.5265 13.00 10.58

    Thank you

    Monday, June 24, 2013 4:18 AM