Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is a stored procedure which i created


ALTER PROCEDURE [dbo].[UpdateInDegrees]
-- Add the parameters for the stored procedure here
@ID int output,@Name nvarchar(100),@Code nvarchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
Declare @ModifiedDateTime Datetime
SET NOCOUNT ON;

Set @ModifiedDateTime = getdate()
-- Insert statements for procedure here
Update Degrees set Name=Upper(@Name),Code=Upper(@Code) where ID=@ID
END



this is a function where i call this stored procedure

public void UpdateInDegrees(TextBox _txtdgname, TextBox _txtdgcode, Label _lbldgID)
{

cm = new SqlCommand();
cm.Connection = cn;
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "UpdateInDegrees";
cm.Parameters.AddWithValue("@Name", _txtdgname.Text);
cm.Parameters.AddWithValue("@Code", _txtdgcode.Text);
cm.Parameters.AddWithValue("@ID", _lbldgID.Text);
cm.ExecuteNonQuery();
}

What I have tried:

ALTER PROCEDURE [dbo].[UpdateInDegrees]
-- Add the parameters for the stored procedure here
@ID int output,@Name nvarchar(100),@Code nvarchar(10)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
Declare @ModifiedDateTime Datetime
SET NOCOUNT ON;

Set @ModifiedDateTime = getdate()
-- Insert statements for procedure here
Update Degrees set Name=Upper(@Name),Code=Upper(@Code) where ID=@ID
END
Posted
Updated 19-May-16 1:46am
Comments
Karthik_Mahalingam 19-May-16 8:26am    
what is your table schema?

1 solution

I'm assuming you want to timestamp your records with a modification date?
If so, either use the @ ModifiedDateTime value you set, or do it directly:
SQL
UPDATE Degrees SET Name=Upper(@Name),Code=Upper(@Code), ModifiedAt = GETDATE() WHERE ID=@ID
 
Share this answer
 

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