fahad sheikhji

fahad sheikhji

  • NA
  • 53
  • 49.4k

hi how to update two tables record together using stored procedure ??or simple query?

May 13 2012 8:46 AM
in my project in aspx page while saving am inserting to two tables one is tblcurrencysale and tblAssets
tblcurrencysale(csID(pk,autoincrement),csPurchaseAmount,csSoldamt,csprofit,csDate)
tblAssets(aID(pk,autoincre),aCash,aDate)
and in tblAssets am adding aCash from csprofit and aDate from csDate..
this is the saving procedure..and i created sp and its working fine..
but while updating ,updating only in tblcurrencysale table.i gave sp..
 
UpdateAllPL objPL=new UpdateAllPL();  objPL.PurchaseAmount=tbPurchase.Text;  objPL.SoldAmount=tbSold.Text;  objPL.Profit=tbProfit.Text;  objPL.Date=tbDate.Text;  UpdateAllBLL objBLL=new UpdateAllBLL();  objBLL.UpdateCurrencySale(objPL);  objPL.aCash=tbProfit.Text;  objPL.aDate=tbDate.Text;  objBLL.UpdateAssets(objPL);  lblMessage.Text="Updated SuccessFully...";  
here is my sp am callin from class file..but Assets table is not updating ..
 
so can u suggest me wat have to do?
 
really it will help for me..thanks

and here is the sp which i created
create proc ups_UpdateCurrencySale @PurchaseAmount varchar(50), @SalesAmount varchar(50), @Profit varchar(50), @Date varchar(50) AS BEGIN Update tblCurrencySale set csPurchaseAmount=@PurchaseAmount,csSalesAmount=@SalesAmount,csProfit=@Profit,csDate=@Date where csPurchaseAmount=@PurchaseAmount end

sp for assets table
create procedure usp_UpdateAssets @Cash varchar(50), @Date varchar(50) AS BEGIn update tblAssets set aCash=@Cash,aDate=@Date where aCash=@Cash end

Answers (3)