这是我之前为此查询提供的例外

问题描述:

file:/// C:/Users/naveen.kumar/Desktop/oledbexception.PNG



更新声明中的语法错误。



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



FROM子句中的语法错误



我尝试过:



更新oledb stmt

cmd =新OleDbCommand(InvoiceItems更新,产品组描述='+ txtProductName +',Quantity ='+ txtQty.Text +',UOM =' + txtUOM.Text +',UnitPrice ='+ txtUnitPrice.Text +',GrossAmount ='+ txtGrossAmount.Text +',VAT ='+ txtVAT.Text +',VatAmount ='+来自InvoiceItems的TxtVatAmount.Text +',Total ='+ txtTotal.Text +',InvoiceNumber = Products.CroductId order by InvoiceNumber ='+ products + conn );



删除oledb stmt

cmd = new OleDbCommand(DELETE FROM InvoiceNumber,INVOICEN O来自InvoiceItems WHERE InvoiceItems.InvoiceNumber = TAXINVOICE.INVOICENO和InvoiceNumber =+ txtInvoice.ToString()+,conn);

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);

查询错误。它应该是这样的:



The query is wrong. It should be something like:

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





我猜你必须更新InvoiceItems表,记住你一次只能更新一个表。



注意:我认为DELETE命令查询也是错误的。



再见



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