Stored Procedure not working but code does?

I am accessing a Stored Procedure from a VB.Net application. I have checked all the values that are assigned to the parameters and they all seem to be correct. I have double-checked the parameter names in the code as well as in the SP...that all checks out Ok as well. When I execute the Stored Procedure from the application...the procedure runs Ok...however the return code on the Insert should be 1 and it's actually 0.

To test this in a different way, I tried using the same parameter values and coded my insert statement within the application and ran it and it worked. So, I'm obviously missing something and need another pair of eyes. Below is my code!

       'This is my code within the VB.Net Application as well as the Class properties used

        Public Function AddUpdateRefCellDisp(ByVal cls As clsRefCellDisp) As String
        Dim retVal As Integer = 0

        Try
            If DBConnection() Then
                cmd = New SqlCommand("", cnn)
                cmd.Parameters.AddWithValue("@ID", cls.ID)                              '@ID                        
                cmd.Parameters.AddWithValue("@CellDispID", cls.CellDispID)              '@CellDispID            
                cmd.Parameters.AddWithValue("@CellDispName", cls.CellDispName)          '@CellDispName            
                cmd.Parameters.AddWithValue("@Capacity", cls.Capacity)                  '@Capacity                  
                cmd.Parameters.AddWithValue("@CellUnit", cls.CellUnit)                  '@CellUnit                  
                cmd.Parameters.AddWithValue("@LoadCellModel", cls.LoadCellModel)        '@LoadCellModel            
                cmd.Parameters.AddWithValue("@LoadCellSN", cls.LoadCellSN)              '@LoadCellSN            
                cmd.Parameters.AddWithValue("@CellUncertainty", cls.CellUncertainty)   '@CellUncertainty      
                cmd.Parameters.AddWithValue("@DisplayModel", cls.DisplayModel)          '@DisplayModel            
                cmd.Parameters.AddWithValue("@DisplaySN", cls.DisplaySN)                '@DisplaySN                  
                cmd.Parameters.AddWithValue("@DisplayUncertainty", cls.DispUncertainty) '@DisplayUncertainty
                cmd.Parameters.AddWithValue("@CDUncertainty", cls.CDUncertainty)        '@CDUncertainty            
                cmd.Parameters.AddWithValue("@NIST", cls.NIST)                          '@NIST                        
                cmd.Parameters.AddWithValue("@CalDate", cls.CalDate)                    '@CalDATe                  
                cmd.Parameters.AddWithValue("@NextCalibration", cls.NextCalibration)    '@NextCalibration      
                cmd.Parameters.AddWithValue("@Interval", cls.Interval)                  '@Interval                  
                cmd.Parameters.AddWithValue("@CalHouseID", cls.CalHouseID)              '@CalHouseID            
                cmd.Parameters.AddWithValue("@TechID", cls.TechID)                      '@TechID                  
                cmd.Parameters.AddWithValue("@Newest", cls.Newest)                      '@Newest                  
                cmd.Parameters.AddWithValue("@extensionDate", cls.ExtensionDate)        '@extensionDate
                cmd.Parameters.AddWithValue("@approver", cls.Approver)                  '@approver      
                cmd.Parameters.AddWithValue("@active", cls.Active)                      '@active                  
                cmd.CommandText = "spAddUpdateRefCellDisp"
                cmd.CommandType = CommandType.StoredProcedure
                'sSQL = "INSERT INTO SystemCellDisp " & _
                '"(CellDispID,CellDispName,Capacity,CellUnit,LoadCellModel,LoadCellSN,CellUncertainty,DisplayModel,DisplaySN,DispUncertainty,CDUncertainty,Nist,CalDate," & _
                ' "NextCalibration,Interval,CalHouseID,TechID,Newest,extensionDate,approver,active) " & _
                '    "VALUES " & _
                '"(" & cls.CellDispID & ",'" & cls.CellDispName & "','" & cls.Capacity & "','" & cls.CellUnit & "','" & cls.LoadCellModel & "','" & cls.LoadCellSN & "'," & cls.CellUncertainty & ",'" & cls.DisplayModel & "','" & _
                '  cls.DisplaySN & "'," & cls.DispUncertainty & "," & cls.CDUncertainty & ",'" & cls.NIST & "','" & cls.CalDate & "','" & cls.NextCalibration & "'," & cls.Interval & "," & cls.CalHouseID & ",'" & cls.TechID & "'," & _
                '  cls.Newest & ",'" & cls.ExtensionDate & "','" & cls.Approver & "'," & cls.Active & ")"

                retVal = cmd.ExecuteNonQuery
                strIOType = "C"
            End If

        Catch ex As Exception
            strErr = "CalDataIO/AddUpdateRefCellDisp() - " & ex.Message
            strIOType = strErr
        End Try

        Return strIOType
    End Function

        'Class for the SystemCellDisp Data Table
    Public Class clsRefCellDisp
        Private _ID As Integer
        Private _CellDispID As Integer
        Private _CellDispName As String
        Private _Capacity As String
        Private _CellUnit As String
        Private _LoadCellModel As String
        Private _LoadCellSN As String
        Private _CellUncertainty As Decimal
        Private _DisplayModel As String
        Private _DisplaySN As String
        Private _DispUncertainty As Decimal
        Private _CDUncertainty As Decimal
        Private _NIST As String
        Private _CalDate As String
        Private _NextCalibration As String
        Private _Interval As String
        Private _calHouseID As Integer
        Private _TechID As String
        Private _Newest As Integer
        Private _IsHide As Integer
        Private _active As Integer
        Private _extensionDate As String
        Private _approver As String

        Property ID() As Integer
            Get
                ID = _ID
            End Get
            Set(value As Integer)
                _ID = value
            End Set
        End Property

        Property CellDispID() As Integer
            Get
                CellDispID = _CellDispID
            End Get
            Set(value As Integer)
                _CellDispID = value
            End Set
        End Property

        Property CellDispName() As String
            Get
                CellDispName = _CellDispName
            End Get
            Set(value As String)
                _CellDispName = value
            End Set
        End Property

        Property Capacity() As String
            Get
                Capacity = _Capacity
            End Get
            Set(value As String)
                _Capacity = value
            End Set
        End Property

        Property CellUnit() As String
            Get
                CellUnit = _CellUnit
            End Get
            Set(value As String)
                _CellUnit = value
            End Set
        End Property

        Property LoadCellModel() As String
            Get
                LoadCellModel = _LoadCellModel
            End Get
            Set(value As String)
                _LoadCellModel = value
            End Set
        End Property

        Property LoadCellSN() As String
            Get
                LoadCellSN = _LoadCellSN
            End Get
            Set(value As String)
                _LoadCellSN = value
            End Set
        End Property

        Property CellUncertainty() As Decimal
            Get
                CellUncertainty = _CellUncertainty
            End Get
            Set(value As Decimal)
                _CellUncertainty = value
            End Set
        End Property

        Property DisplayModel() As String
            Get
                DisplayModel = _DisplayModel
            End Get
            Set(value As String)
                _DisplayModel = value
            End Set
        End Property

        Property DisplaySN() As String
            Get
                DisplaySN = _DisplaySN
            End Get
            Set(value As String)
                _DisplaySN = value
            End Set
        End Property

        Property DispUncertainty() As Decimal
            Get
                DispUncertainty = _DispUncertainty
            End Get
            Set(value As Decimal)
                _DispUncertainty = value
            End Set
        End Property

        Property CDUncertainty() As Decimal
            Get
                CDUncertainty = _CDUncertainty
            End Get
            Set(value As Decimal)
                _CDUncertainty = value
            End Set
        End Property

        Property NIST() As String
            Get
                NIST = _NIST
            End Get
            Set(value As String)
                _NIST = value
            End Set
        End Property

        Property CalDate() As String
            Get
                CalDate = _CalDate
            End Get
            Set(value As String)
                _CalDate = value
            End Set
        End Property

        Property NextCalibration() As String
            Get
                NextCalibration = _NextCalibration
            End Get
            Set(value As String)
                _NextCalibration = value
            End Set
        End Property

        Property Interval() As Integer
            Get
                Interval = _Interval
            End Get
            Set(value As Integer)
                _Interval = value
            End Set
        End Property

        Property CalHouseID() As Integer
            Get
                CalHouseID = _calHouseID
            End Get
            Set(value As Integer)
                _calHouseID = value
            End Set
        End Property

        Property TechID() As String
            Get
                TechID = _TechID
            End Get
            Set(value As String)
                _TechID = value
            End Set
        End Property

        Property Newest() As Integer
            Get
                Newest = _Newest
            End Get
            Set(value As Integer)
                _Newest = value
            End Set
        End Property

        Property IsHide() As Integer
            Get
                IsHide = _IsHide
            End Get
            Set(value As Integer)
                _IsHide = value
            End Set
        End Property

        Property ExtensionDate() As String
            Get
                ExtensionDate = _extensionDate
            End Get
            Set(value As String)
                _extensionDate = value
            End Set
        End Property

        Property Approver() As String
            Get
                Approver = _approver
            End Get
            Set(value As String)
                _approver = value
            End Set
        End Property

        Property Active() As Integer
            Get
                Active = _active
            End Get
            Set(value As Integer)
                _active = value
            End Set
        End Property
        '
        '
        '
        Public Sub New()

        End Sub
    End Class


Here is my Stored Procedure

    ALTER PROCEDURE [FUTEKLOCAL\blake].[spAddUpdateRefCellDisp]
      @ID                              INT,
      @CellDispID                  INT,
      @CellDispName            VARCHAR(50),
      @Capacity                  VARCHAR(100),
      @CellUnit                  VARCHAR(20),
      @LoadCellModel            VARCHAR(20),
      @LoadCellSN                  VARCHAR(20),
      @CellUncertainty      DECIMAL(18,7),
      @DisplayModel            VARCHAR(20),
      @DisplaySN                  VARCHAR(20),
      @DisplayUncertainty      DECIMAL(18,7),
      @CDUncertainty            DECIMAL(18,7),
      @NIST                        VARCHAR(50),
      @CalDATe                  VARCHAR(50),
      @NextCalibration      VARCHAR(50),
      @Interval                  INT,
      @CalHouseID                  INT,
      @TechID                        VARCHAR(50),
      @Newest                        INT,
      @extensionDate            VARCHAR(50),
      @approver                  VARCHAR(50),
      @active                        INT
AS
BEGIN

      IF EXISTS (SELECT COUNT(*) FROM SystemCellDisp WHERE ID = @ID)
            BEGIN
                  UPDATE      SystemCellDisp
                     SET      CellDispID = @CellDispID,
                              CellDispName = @CellDispName,
                              Capacity = @Capacity,
                              CellUnit = @CellUnit,
                              LoadCellModel = @LoadCellModel,
                              LoadCellSN = @LoadCellSN,
                              CellUncertainty = @CellUncertainty,
                              DisplayModel = @DisplayModel,
                              DisplaySN = @DisplaySN,
                              DispUncertainty = @DisplayUncertainty,
                              CDUncertainty = @CDUncertainty,
                              Nist = @NIST,
                              CalDate = @CalDATe,
                              NextCalibration = @NextCalibration,
                              Interval = @Interval,
                              CalHouseID = @CalHouseID,
                              TechID = @TechID,
                              Newest = @Newest,
                              --IsHide = @IsHide
                              extensionDate = @extensionDate,
                              approver = @approver,
                              active = @active
                   WHERE      ID = @ID
             
                  RETURN
            END
      ELSE
            BEGIN
                  INSERT INTO SystemCellDisp
                        (CellDispID,
                           CellDispName,
                           Capacity,
                           CellUnit,
                           LoadCellModel,
                           LoadCellSN,
                           CellUncertainty,
                           DisplayModel,
                           DisplaySN,
                           DispUncertainty,
                           CDUncertainty,
                           Nist,
                           CalDate,
                           NextCalibration,
                           Interval,
                           CalHouseID,
                           TechID,
                           Newest,
                           extensionDate,
                           approver,
                           active)
                   VALUES
                        (@CellDispID,
                         @CellDispName,
                         @Capacity,
                         @CellUnit,
                         @LoadCellModel,
                         @LoadCellSN,
                         @CellUncertainty,
                         @DisplayModel,
                         @DisplaySN,
                         @DisplayUncertainty,
                         @CDUncertainty,
                         @NIST,
                         @CalDATe,
                         @NextCalibration,
                         @Interval,
                         @CalHouseID,
                         @TechID,
                         @Newest,
                         @extensionDate,
                         @approver,
                         @active)
                         
                  RETURN                     
            END      
END
BlakeMcKennaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BlakeMcKennaAuthor Commented:
Well I made some progress. In my SP, I commented out all the code from the IF Statement to the ELSE...basically where the INSERT would be the only thing to execute. I ran my app where it executed the SP and it worked. So, I believe that it has something to do with my logic in that IF Statement...which doesn't surprise me since writing SQL code isn't my strong suite...
0
BlakeMcKennaAuthor Commented:
Ok,

Ran another test and that worked. I fixed it. For some reason my SELECT statement wasn't working...not sure why but that was it. I changed it from SELECTING COUNT(*) to SELECT ID and that seemed to work. If anyone has a reason why this worked and the other didn't, I would appreciate if someone could share that with me.

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.