Hi!
I'm a beginner to VB.NET. I'm working on an application which is created using VB.NET 2005 and the DB is created in SQL server 2005. I'm able to delete a record from a table when it is not used in another table as a Foreign Key.
For eg. If I create a new Customer and saves it in Customer Table, i can delete it with out any problems using the following code..
If .DeleteCancelbutton.Text = "&Delete" Then
deleteDialogResult = MessageBox.Show("Delete this record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If deleteDialogResult = Windows.Forms.DialogResult.Yes Then
.CustomerBindingSource.RemoveCurrent()
.CustomerTableAdapter.Update(.ProjectPrototypeV2DataSet.Customer)
.ToolStripStatusLabel1.Text = " Record Deleted"
End If
But if i add a SITE to that customer, then try to delete the Customer, It deletes the customer, but does not delete the related SITE.
I tried setting the foreign key constriants to DELETE CASCADE, but then I can't load the tables using the Fill method to the Tableadapters... gives an error saying something about too much forign key constraints. currently i'm only having relational constraints.
is there a method which I use to delete a record from a table and delete all the information in other tables that are related to the deleted record?
I was thinking of using a Stored Procedure, but I don't know how to call a Stored procedure in the forms. I'm using TableAdapters and Bindingsource to get data to the froms...
Can any one please help me....
Ishani