Updating fields from two tables of Sql CE in C#? -
i have 2 tables in stock.sdf database called:
product (pid, pname, unitprice) sales (pid, qty, totalprice) i want add totalprice sales table using update query. because want store data permanently, whenever new sales added.
sales.totalprice = (sales.qty * product.unitprice sales.pid = product.pid); i have tried follows , got parsing error. possible solution
try { stockdbconnection dbcon = new stockdbconnection(); sqlceconnection conn = new sqlceconnection(dbcon.returnconnection("connstring")); conn.open(); sqlcecommand command = new sqlcecommand("update set a.tprice=@qty * b.uprice sales join product b on @pid=b.pid", conn); command.parameters.add("@qty", txtqty.text); command.parameters.add("@pid", cmbpid.text); command.executenonquery(); messagebox.show("data upated successfully."); } catch (exception exp) { messagebox.show(exp.message); }
try query
update set a.totalprice=a.qty * b.unitprice sales join product b on a.pid=b.pid
Comments
Post a Comment