Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:30:05+00:00 2026-05-28T00:30:05+00:00

I have written a simple stored procedure for updating a record which isn’t working

  • 0

I have written a simple stored procedure for updating a record which isn’t working but I can’t work out why. No exceptions are thrown but the record doesn’t update either.

See code below:

public int IMGId;

protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string result = "";
        string sSQL = "usp_imageloader_update";


        using (SqlConnection dbConnection = new SqlConnection(CKS_app_settings.sql_conn_string_db))
        {
            // SqlTransaction tn=null;   
            try
            {
                dbConnection.Open();
                //start Transaction
                // tn = dbConnection.BeginTransaction();
                SqlCommand command = new SqlCommand(sSQL, dbConnection);
                //command.Transaction = tn;
                command.CommandText = sSQL;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandTimeout = 1024;
                command.Parameters.AddWithValue("@p_image_id", IMGId);
                command.Parameters.AddWithValue("@p_url", txtUrl.Text);
                command.Parameters.AddWithValue("@p_alt_text", txtAlt.Text);
                //command.Parameters.AddWithValue("@p_filepath", File1.Value);
                //command.Parameters.AddWithValue("@p_cntr_id", str_id);
                int rowsAffected = command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
               // throw ex;

                //If it failed for whatever reason, rollback the //transaction
                //tn.Rollback();                          
                //No need to throw because we are at a top level call and //nothing is handling exceptions
                result = ex.InnerException.Message;
            }
        }

Stored procedure in SQL SERVER

USE [smsdb_test_griffin2]
GO
/****** Object:  StoredProcedure [dbo].[usp_imageloader_update]    Script Date: 01/04/2012   09:05:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER    procedure [dbo].[usp_imageloader_update]
@p_image_id INT,
@p_url  VARCHAR(255),
@p_alt_text VARCHAR(255)
as 

UPDATE Image_Library_UK 
SET  
Url=@p_url,
Alt_text=@p_alt_text 

WHERE Image_id=@p_image_id
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:30:05+00:00Added an answer on May 28, 2026 at 12:30 am

    Having tried it in isolation, assuming that this works ( and there is nothing glaringly obvious wrong ), I would assume that one of your parameters is not being set correctly. It could be that the IMGid is not right – which would have this effect – or it coudl be that the the url and alttext have already be reset to their values by the load of the page.

    Check the values at the point of calling. It may be you need to use !Page.IsPostBack to not reset these values on a postback. It may be that you need to access them using the request variable – it does depend on the rest of your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure which is written in c#: SqlConnection scn = new
I have written a simple CRUD form which has one select list. However the
I have written a simple jQuery.ajax function which loads a user control from the
I have written a CLR stored procedure that is in an assembly. I have
I have written a fairly simple lazy loading proxy class, which I have documented
I am having a strange problem with MySQL Stored Procedure. I have written a
I have a stored procedure written in T-SQL and want to use a table
I have written simple first stage bootloader which displays Hello world using interrupt to
I have written a simple file upload script but it gives me the error
I have written a simple WCF service that accepts and stores messages. It works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.