Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
file:///C:/Users/naveen.kumar/Desktop/oledbexception.PNG

Syntax error in Update statement.

file:///C:/Users/naveen.kumar/Desktop/syntax%20error%20for%20delete%20stst.PNG

Syntax error in FROM Clause

What I have tried:

Update oledb stmt
cmd = new OleDbCommand("UPDATE from InvoiceItems,Products 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 where InvoiceItems.ProductId = Products.ProductId order by InvoiceNumber='" + txtInvoice.Text.Trim() + "'", conn);

Delete oledb stmt
cmd = new OleDbCommand("DELETE FROM InvoiceNumber,INVOICENO from InvoiceItems WHERE InvoiceItems.InvoiceNumber=TAXINVOICE.INVOICENO and InvoiceNumber=" + txtInvoice.ToString() + "", conn);
Posted
Updated 13-Oct-16 22:00pm

1 solution

The query is wrong. It should be something like:

SQL
UPDATE InvoiceItems SET <<fields>> FROM InvoiceItems, Products where <<where conditions>>


I guess you have to update the InvoiceItems table, remember you can update only a table at a time.

Note: I think that also the DELETE command query is wrong.

Bye
 
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