2
Answers

insert update query in sql server

hi any buddy help please
 
i have one sp in which i will insert and update up product like this:
 
 
 
Create PROCEDURE [dbo].[Sp_AddToMyCart]
@SessionId varchar(500),
@Product_Fkid int,
@size_Fkid int,
@Qty int
AS
Declare @count int,@ReturnValue int
BEGIN
Set @count=(Select COUNT(1) from dbo.MyCart where SessionId=@SessionId and Product_Fkid=@Product_Fkid)
if(@count=0)
begin
Insert into dbo.MyCart(SessionId,Product_Fkid,Qty,size_Fkid) values (@SessionId,@Product_Fkid,@Qty,@size_Fkid)
Set @ReturnValue=1
end
 
 
else
begin
update dbo.MyCart
Set Qty=@Qty
where SessionId=@SessionId and Product_Fkid=@Product_Fkid
Set @ReturnValue=2
end
return @ReturnValue
END
 
 
 
insert update work properly but i face a problem when
i want insert same product then it return this product already add in your cart
 
 
 
 
 
Answers (2)
1
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.4k 8y
Hi,
 
Follow this steps :
 
Step 1 : Select your article.
 
http://www.c-sharpcorner.com/UploadFile/2a6dc5/how-to-send-a-email-using-Asp-Net-C-Sharp/
 
Step 2 : Bookmarking Article
 
 
Step 3 : Go to your My Account and Click BookMark.
 
http://www.c-sharpcorner.com/myaccount/
 
 
Step 4 : Click Book Mark.
 
Accepted
0
Ravi Patel

Ravi Patel

NA 7.8k 532.4k 8y
Yes you can bookmark the articles for future reference
 
check this
http://www.c-sharpcorner.com/forums/how-to-use-bookmark-in-c-sharpcorner