Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
I need to update the oledb command in order to delete the entire record involved in two tables using Inner Join condition

What I have tried:

C#
"DELETE FROM InvoiceNumber,INVOICENO from InvoiceItems WHERE InvoiceItems.InvoiceNumber=TAXINVOICE.INVOICENO and InvoiceNumber=" + txtInvoice.ToString() + ""
Posted
Updated 16-Oct-16 23:40pm
v3

You can use sub query that will return the list of id that satisfy the condition of your join.
and in where clause of delete you should use 'in' keyword for filtering
 
Share this answer
 
If you want to remove records from both tables - InvoiceItems and TAXINVOICE then try using INNER JOIN, something like following-
C#
"DELETE InvoiceNumber,TAXINVOICE FROM InvoiceItems INNER JOIN TAXINVOICE WHERE InvoiceItems.InvoiceNumber=TAXINVOICE.INVOICENO and InvoiceNumber=" + txtInvoice.Text


Note: Have changed txtInvoice.ToString() to txtInvoice.Text considering it to be a textbox

Please let me know if your requirement is different than this.
Hope, it helps :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900