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 3597914
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:10:40+00:00 2026-05-18T20:10:40+00:00

My code is as shown below : using (SqlConnection _conn = new SqlConnection(ConfigurationManager.ConnectionStrings[DarmanConnectionString].ToString())) {

  • 0

My code is as shown below :

using (SqlConnection _conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DarmanConnectionString"].ToString()))
{
    using (SqlCommand _cmd = new SqlCommand("dbo.sp_Noskheh_SumOfTotalPay", _conn))
    {
        _cmd.CommandType = CommandType.StoredProcedure;
        _cmd.Parameters.Add(new SqlParameter("@Co_ID", int.Parse(Session["Co_ID"].ToString())));

        _cmd.Parameters.Add(new SqlParameter("@RETURN_VALUE", SqlDbType.NVarChar));
        _cmd.Parameters["@RETURN_VALUE"].Direction = ParameterDirection.ReturnValue;

        _conn.Open();
        _cmd.ExecuteNonQuery();

        Int64 result = Int64.Parse(_cmd.Parameters["@RETURN_VALUE"].Value.ToString());
        lblSumTotalPayShow.Text = result.ToString();

            _conn.Close();
        }
    }

my SP is like this :

create Procedure [dbo].[sp_Noskheh_SumOfTotalPay]
    @Co_ID int
As    
    -----------------
    Declare @Sum nvarchar(50)
    -----------------    
BEGIN
    Select @Sum = convert(nvarchar(50), SUM(TotalPay))
    From Noskheh
    Where (Co_ID = @Co_ID)

    Return @Sum
END

and the error is in line (_cmd.ExecuteNonQuery();):

Error:

Sys.WebForms.PageRequestManagerServerErrorException: The conversion of
the nvarchar value ‘3955811801’ overflowed an int column. The
‘sp_Noskheh_SumOfTotalPay’ procedure attempted to return a status of
NULL, which is not allowed. A status of 0 will be returned instead.

Would you please help me to figure out this problem?

  • 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-18T20:10:41+00:00Added an answer on May 18, 2026 at 8:10 pm

    You are trying to convert a nvarchar value to a int

    The Return statement must be an integer.

    Try changing your approach and in your Stored Proc do

    Select @Sum instead of return @sum

    Then instead of using ExecuteNonQuery use ExecuteScalar

    String result = (String)cmd.ExecuteScalar();
    lblSumTotalPayShow.Text = result.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code is as shown below : using (SqlConnection _conn = new SqlConnection(ConfigurationManager.ConnectionStrings[DarmanConnectionString].ToString())) {
Okay, so I've got the following code shown below to create a dialog using
This is a small piece of code shown below which is using do while
I am using the code shown below to get Data from our server where
I'm using the Kal calendar . For the code shown below I'm referring to
My code shown below will successfully return an array of values using print_r. How
I'm trying to read an Excel (xlsx) file using the code shown below. I
I wrote a code as shown below to print stack trace. I am using
I am using this slice of code (shown below) in an attempt to populate
My code is this : SqlConnection scn = new SqlConnection(ClsPublic.GetConnectionString()); SqlCommand scm = new

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.