You must Sign In to post a response.
  • Category: ASP.NET

    Output parameter returns null

    Hi,

    In my stored procedure output parameter returns null in value in business logic class below i put my SP and business logic code.

    Can anybody guide to me?

    alter Procedure BD_InsertMobileClient_GpsLogPlanogram
    (
    @SalesPersonID int,
    @MobileRowID int,
    @StatusCode int output
    )
    AS
    INSERT INTO dbo.tblGpsplanogram
    (
    SalespersonID,
    MobileGpsRowID

    )
    VALUES
    (
    @SalesPersonID,
    @MobileRowID
    )

    Declare @CurrentrowID int;
    set @CurrentrowID = @@IDENTITY
    select @StatusCode = MobileGpsRowID from tblGpsplanogram
    where ID = @CurrentrowID
    RETURN @StatusCode

    Business logic:

    public int InsertBdDetails()
    { try
    {
    SqlParameter[] paramStock =
    {
    new SqlParameter("@SalesPersonID", SqlDbType.Int, 50,ParameterDirection.Input,false,0,0,"SalespersonID",DataRowVersion.Original,sSalesPersonID),
    new SqlParameter("@MobileRowID",SqlDbType.Int, 30,ParameterDirection.Input,false,0,0,"MobileGpsRowID",DataRowVersion.Original,MobileRowID),
    new SqlParameter("@StatusCode",SqlDbType.Int,30,ParameterDirection.Output,false,0,0,"",DataRowVersion.Original,StockStausCode)
    };
    SqlHelper.ExecuteNonQuery("BD_InsertMobileClient_GpsLogPlanogram", paramStock);
    if (StockStausCode > 0)
    {
    StockStausCode = Convert.ToInt32(paramStock[2].Value);

    }
    return StockStausCode ;
    }
    catch (Exception ex)
    {
    objErrorHandler.LogError(1, "BlmrmService", "InsertBdDetails", ex.Message, "", "1");
    throw ex;
    }
    }


    Thanks and regards
    brite
  • #762734
    I got solution

    public int InsertBdDetails()
    { try
    {
    SqlParameter[] paramStock =
    {
    new SqlParameter("@SalesPersonID", SqlDbType.Int, 50,ParameterDirection.Input,false,0,0,"SalespersonID",DataRowVersion.Original,sSalesPersonID),
    new SqlParameter("@MobileRowID",SqlDbType.Int, 30,ParameterDirection.Input,false,0,0,"MobileGpsRowID",DataRowVersion.Original,MobileRowID),
    new SqlParameter("@StatusCode",SqlDbType.Int,30,ParameterDirection.Output,false,0,0,"",DataRowVersion.Original,0)
    };
    SqlHelper.ExecuteNonQuery("BD_InsertMobileClient_GpsLogPlanogram", paramStock);

    if (paramStock[2].Value != null)
    {
    StockStausCode = Convert.ToInt32(paramStock[2].Value);
    }
    else
    {
    StockStausCode=0;

    }
    return StockStausCode;
    }
    catch (Exception ex)
    {
    objErrorHandler.LogError(1, "BlmrmService", "InsertBdDetails", ex.Message, "", "1");
    throw ex;
    }
    }

  • #762744
    Hi,

    First off all check the output parameter value in backend what it returns exactly, if it returns the data perfectly then debug your code and check it one more time to find the issue.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments