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

  • SEARCH
  • Home
  • 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 8993961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:18:45+00:00 2026-06-15T23:18:45+00:00

I am running a stored procedure with a hardcoded value. The command executes successfully

  • 0

I am running a stored procedure with a hardcoded value. The command executes successfully without any errors. But data is not updating in the database. If I run that stored procedure with SQL Server, data is updating. What’s my mistake?

C# code

using (SqlTransaction sqlTrans = con.BeginTransaction())
{
    using (SqlCommand AdjustTax = new SqlCommand("GP_SOP_AdjustTax", con, sqlTrans))
    {
        try
        {
            AdjustTax.CommandType = CommandType.StoredProcedure;
            AdjustTax.Parameters.Add("@IN_SOPType", SqlDbType.Int).Value = 3;
            AdjustTax.Parameters.Add("@IN_SOPNo", SqlDbType.VarChar).Value = "stdinv2278";
            AdjustTax.Parameters.Add("@IN_AdjustAmount", SqlDbType.Int).Value = 0.04;
            AdjustTax.Parameters.Add("@O_iError", SqlDbType.Int, 250);
            AdjustTax.Parameters["@O_iError"].Direction = ParameterDirection.Output;

            if (con == null || con.State == ConnectionState.Closed)
            {
                con.Open();
            }

            AdjustTax.ExecuteNonQuery();
            int Error = (int)AdjustTax.Parameters["@O_iError"].Value;

            if (Error == 0)
            {
                MessageBox.Show("Tax is Adjusted");
            }
            if (Error != 0)
            {
                MessageBox.Show("Error No:" + Error1);
            }

            sqlTrans.Commit();
        }

        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            sqlTrans.Rollback();
        }

        finally
        {
            con.Close();
        }
    }
}

SQL Server code

DECLARE @return_value int,
        @O_iError int

EXEC    @return_value = [dbo].[GP_SOP_AdjustTax]    
        @IN_SOPType = 3,   
        @IN_SOPNo = 'stdinv2278',    
        @IN_AdjustAmount = 0.04,    
        @O_iError = @O_iError OUTPUT

SELECT  @O_iError as N'@O_iError'

SELECT  'Return Value' = @return_value

GO
  • 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-06-15T23:18:47+00:00Added an answer on June 15, 2026 at 11:18 pm

    I think the problem is being caused by this line:

    AdjustTax.Parameters.Add("@IN_AdjustAmount", SqlDbType.Int).Value = 0.04;
    

    Since the type is SqlDbType.Int and you are passing in 0.04, that value is most likely getting rounded to 0. Without seeing the contents of the actual stored procedure, I can only guess that passing in a value of 0 for that parameter either causes the stored procedure to skip the update, or the calculation that the stored procedure does results in the column being updated to the same value it originally had.

    I would try changing that line to:

    AdjustTax.Parameters.Add("@IN_AdjustAmount", SqlDbType.Decimal).Value = 0.04M
    

    EDIT
    Decimal is the proper mapping for the Numeric Sql Type, as explained here.

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

Sidebar

Related Questions

I'm running a stored procedure through L2S and it's returning 'Specified cast is not
When running a stored procedure, we're getting the error 297 The user does not
getting really close to running my first stored procedure. This one compiles but when
Is there any examples to be found for running a stored procedure on serviceStack
i am running a stored procedure to delete data from two tables: delete from
I have a somewhat-long-running stored procedure being called from a PB application. I want
I'm running a stored procedure that involves more tables placed in joins. My stored
I'm running the following stored procedure and there's a join of Classes and Dates
I am running the following stored procedure to delete large number of records. I
I've got a T-SQL stored procedure running on a Sybase ASE database server that

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.