Click here to Skip to main content
15,903,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to update my main table: mIngenicoDetail

The columns looks as follows

TerminalID(PK)
PropertyID(FK)-Linked to a lookup table
SimNr
Location
SerialNr
DepartmentID(FK)-Linked to a lookup table
FunctionID(FK)-Linked to a lookup table
NetworkID(FK)-Linked to a lookup table
Version
DateInserted
Active(BIT)

I have written a short proc. I am inputting the new values from textboxes that should update the table. My code is working, but my tables data do not want to update. There must be something wrong with my Sql code.

This is what i have written.


ALTER PROCEDURE [dbo].[PUPD_IngenicoDetials] 

@Simnr VARCHAR(50),
@Location VARCHAR(50),
@Serialnr VARCHAR(50),
@Department VARCHAR(50),
@Functions VARCHAR(50),
@Network VARCHAR(50),
@Version VARCHAR(50),
@Date VARCHAR(50),
@RadicalRef VARCHAR(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	UPDATE dbo.mIngenicoDetail 
	SET Simnr = @Simnr,Location = @Location, 
	Serialnr = @Serialnr, DepartmentID = @Department, FunctionID = @Functions,
	NetworkID = @Network, Version=@Version, DateInserted=@Date
    FROM mIngenicodetail
	
	
END
GO

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO


Can you please assist.

Thank you
Posted

1 solution

I would suggest:
SQL
ALTER PROCEDURE [dbo].[PUPD_IngenicoDetials] 
@TerminalID [set the correct datatype],
@Simnr VARCHAR(50),
@Location VARCHAR(50),
@Serialnr VARCHAR(50),
@Department VARCHAR(50),
@Functions VARCHAR(50),
@Network VARCHAR(50),
@Version VARCHAR(50),
@Date VARCHAR(50),
@RadicalRef VARCHAR(50)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	UPDATE dbo.mIngenicoDetail 
	SET Simnr = @Simnr,Location = @Location, 
	Serialnr = @Serialnr, DepartmentID = @Department, FunctionID = @Functions,
	NetworkID = @Network, Version=@Version, DateInserted=@Date
    Where TerminalID = @TerminalID	
	
END
GO
 
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
 
Share this answer
 
v2
Comments
JacoBosch 24-Jan-12 5:25am    
The TerminalID must not Update. Only the rest of the records must update.
Herman<T>.Instance 24-Jan-12 9:42am    
by stating 'Where TerminalID = @TerminalID' you do not update the terminalID but you tell sql that is has to update that row with the fields and values stated in the set section.

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