Click here to Skip to main content
15,891,629 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to populate update command in stored procedure
Posted
Comments
Mehdi Gholam 29-May-15 3:31am    
Your question makes little sense, edit it and add more information on what you are trying to do.
V Senthil Kumar 29-May-15 3:36am    
what is the code for update stored procedure in sql and cs
Aditya Chauhan 29-May-15 3:41am    
do you want to update data from stored procedure or update stored procedure
Abhipal Singh 29-May-15 3:43am    
I guess by using parameters.. :)

However, you need to be more specific in your question. Can you please explain what exactly you are stuck with...? I have not developed telepathic abilities till date.. :-p

1 solution

SQL
CREATE PROCEDURE DoUpdate
    @ID INT,
    @Value NVARCHAR(MAX)
AS
BEGIN
   UPDATE MyTable SET ValueColumnName=@Value WHERE Id=@ID
END
GO
Then:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("DoUpdate", con))
        {
        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.AddWithValue("@ID", iDOfRow);
        com.Parameters.AddWithValue("@Value", "My new string");
        com.ExecuteNonQuery();
        }
 
Share this answer
 
Comments
V Senthil Kumar 29-May-15 3:50am    
ya i need this only thankyou.
OriginalGriff 29-May-15 4:13am    
You're welcome!

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