I have an Access Database in which some tables are created like TAXINVOICE with columns like INVOICENO,MOBILENUMBER,CUSTOMERNAME,ADDRESS1,ADDRESS2,TINNO,PONO,TRANSPORT,BILLDATE,
InvoiceType,PODATE,totalGrossAmt,totalVatAmt,BILLAMT,TRANSPORTAMT,OTHERAMT,FINALAMT,
ROUNDOFF,GRANDTOTAL,STATUS
another table InvoiceItems with columns InvoiceItemId,InvoiceNumber,ProductId,Quantity,UOM,UnitPrice,GrossAmount,VAT,VatAmount,
Total
and a Table Products with columns
ProductId and ProductName
My problem is to update and delete whatever the entries we have edited in the datagridview form from windows application (C#.NET code).I used OLEDB queris which are tried and I will add below
What I have tried:
This is update statement for update button click code
try
{
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);
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Success");
conn.Close();
DisplayData();
ClearData();
}
catch (OleDbException ex)
{
MessageBox.Show("Empty xseries");
throw(ex);
}
This is delete statement for update button click code
try
{
cmd = new OleDbCommand("DELETE FROM InvoiceNumber,INVOICENO from InvoiceItems WHERE InvoiceItems.InvoiceNumber=TAXINVOICE.INVOICENO and InvoiceNumber=" + txtInvoice.ToString() + "", conn);
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Deleted Entry");
conn.Close();
DisplayData();
ClearData();
}
catch (OleDbException ex)
{
MessageBox.Show("ALL rows are inevitable");
throw(ex);
}