Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi good morning everyone..

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
Posted
Updated 10-May-12 19:26pm
v3
Comments
Ganesan Senthilvel 11-May-12 0:35am    
Share your SP code to validate
ythisbug 11-May-12 1:16am    
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 ..
Rahul Rajat Singh 11-May-12 1:30am    
Where is the stored procedure? this is you code.
ythisbug 11-May-12 1:37am    
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
Sandeep Mewara 11-May-12 1:43am    
Where is Asset update SP/Query?

look man i don't understand good but if you always use them together i advise to put them in one procedure or if you use each alone in your code so create new procedure and combine them together in one procedure in this way you can call the proc one time it is nice regards
 
Share this answer
 
Comments
Sandeep Mewara 11-May-12 1:51am    
Well how does that resolve the thing?
ythisbug 11-May-12 2:12am    
ok thanks youssef
ythisbug 11-May-12 2:15am    
hi can u tel me how to create together sp..
Is this query correct and doing what you want to?

Updating a field where using the same field in the WHERE clause looks incorrect:
SQL
set aCash=@Cash,aDate=@Date where aCash=@Cash


Assigning a cash based on new cash itself in the where clause will not find the data most of the times.
Currently, if any row already has the same amount as the new amount passed to be updated, query would work or else not.

1. There should be some unique id to find the unique row record to update
2. You are directly passing the data of textbox to DB, trim it. (As such you should also take care of datatype but to start with, you can live with it!)

BTW, I assume you DEBUGGED and there was no runtime error, only logical.
 
Share this answer
 
v2
Comments
ythisbug 11-May-12 2:13am    
ya thanks sandeep
Whats the relation between both the table.. make a relation between both table and put it in where clause in update query of tblassets(I maked it underline). either I dont know about your requirement but then also, I think you have to update your tblcurrencySale through a identity field not by purchase amount

SQL
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 


update tblAssets set aCash=@Profit,aDate=@Date where aCash=@Cash

end



Thanks
 
Share this answer
 
Comments
ythisbug 13-May-12 8:05am    
after this how to call this function in updatebutton click..can u suggest me?i tried but both tables records r not updating

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