I have a txtbox and a button submit, what i want to acheive is if user wantd to insert records the code will check if the data has been
inserted the first time if not insert but if yes update the existing record.
This is my insert procedure
-- =============================================
-- Author: <Author,,>
-- Create date: <Create Date,,>
-- =============================================
ALTER PROCEDURE [dbo].[InsertFiveInchesMMORDERNkwereSore]
@UserName nvarchar (100),
@Phone nvarchar (100),
@Location nvarchar (50),
@Item nvarchar (100),
@Inches nvarchar (100),
@BlockCategory nvarchar (500),
@PaymentMethod nvarchar (500),
@OrderStatus nvarchar(500),
@Stock float,
@QuantityOrdered float,
@Discount money,
@UnitPrice money,
@OrderDate date
AS
INSERT INTO [FiveInchesMMORDERNkwereStore]
([UserName]
,[Phone]
,[Location]
,[Item]
,[Inches]
,[BlockCategory]
,[PaymentMethod]
,[OrderStatus]
,[Stock]
,[QuantityOrdered]
,[Discount]
,[UnitPrice]
,[OrderDate])
VALUES
(
@UserName,
@Phone,
@Location,
@Item ,
@Inches,
@BlockCategory,
@PaymentMethod,
@OrderStatus,
@Stock,
@QuantityOrdered,
@Discount,
@UnitPrice,
@OrderDate
)
------Update Quantity by subtracting it from @Qty
UPDATE FiveInchesMMNkwereStore SET [BlockQuantity] = [BlockQuantity]-@QuantityOrdered WHERE [UserName]= @UserName
select SCOPE_IDENTITY() as UserID