Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have tried to update the query but it was unsuccessful I want Innerjoin statements
cmd = new OleDbCommand("UPDATE InvoiceItems set Description ='" + txtProductName + "',Quantity = '" + txtQty.Text + "',UOM = '" + txtUOM.Text + "',UnitPrice ='" + txtUnitPrice.Text + "',GrossAmount ='" + txtGrossAmount.Text + "',VAT = '" + txtVAT.Text + "',VatAmount ='" + txtVatAmount.Text + "',Total ='" + txtTotal.Text + "', from InvoiceItems,Products INNERJOIN InvoiceItems.ProductId = Products.ProductId where InvoiceNumber='" + txtInvoice.Text.Trim() + "'", conn);

What I have tried:

cmd = new OleDbCommand("UPDATE InvoiceItems set Description ='" + txtProductName + "',Quantity = '" + txtQty.Text + "',UOM = '" + txtUOM.Text + "',UnitPrice ='" + txtUnitPrice.Text + "',GrossAmount ='" + txtGrossAmount.Text + "',VAT = '" + txtVAT.Text + "',VatAmount ='" + txtVatAmount.Text + "',Total ='" + txtTotal.Text + "', from InvoiceItems,Products INNERJOIN InvoiceItems.ProductId = Products.ProductId where InvoiceNumber='" + txtInvoice.Text.Trim() + "'", conn);
Posted
Updated 13-Oct-16 23:13pm

1 solution

I'm pretty sure that the first thing they would have told you is: Don't do it like that. Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
And have a look at the syntax of a JOIN clause: INNER JOIN tableName optionalTableAlias ON condition WHERE ... not INNERJOIN condition WHERE ...
 
Share this answer
 
Comments
Maciej Los 14-Oct-16 16:56pm    
+5

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