troubleshooting Question

ADO.NET "Argument 'Number' is not a valid value." << "Number" Does Not Exist

Avatar of bobcann
bobcannFlag for United States of America asked on
Visual Basic.NET
6 Comments2 Solutions1888 ViewsLast Modified:
No, it is not a typo error in my code. There are no numbers in the parameters, so this came out of nowhere. The parameter "Number" is nowhere to be found.  This is odd and I have no idea how to fix this. I tried dropping the stored proc and re-creating, but the error persists.

Can anyone offer a suggestion on how ti fix this? Code is below.

Thanks for any help.


"System.ArgumentException: Argument 'Number' is not a valid value.
   at Microsoft.VisualBasic.ErrObject.Raise(Int32 Number, Object Source, Object Description, Object HelpFile, Object HelpContext)
   at Personnel.EmployeeEmergencyContactsUpdate(String strSSN, String strEmergencyRelation, String strEmergencyName, String strEmergencyAddress, String strEmergencyCity, String strEmergencyState, String strEmergencyZipCode, String strEmergencyApartment, String strEmergencyPhone, String strEmergencyWorkPhone, String strEmergencyWorkPhoneExt, String strEnteredBy) in C:\Documents\STS_Rewrite\STS (to DOT(60FE).NET) ()\App_Code\Personnel.vb:line 1472
   at WebService._EmployeeEmergencyContactsUpdate() in C:\Documents\STS_Rewrite\STS (to DOT(60FE).NET) ()\App_Code\WebService.vb:line 85"
VB.NET-----------------------------------------

Public Sub EmployeeEmergencyContactsUpdate( _
        ByVal strSSN As String, _
        ByVal strEmergencyRelation As String, _
        ByVal strEmergencyName As String, _
        ByVal strEmergencyAddress As String, _
        ByVal strEmergencyCity As String, _
        ByVal strEmergencyState As String, _
        ByVal strEmergencyZipCode As String, _
        ByVal strEmergencyApartment As String, _
        ByVal strEmergencyPhone As String, _
        ByVal strEmergencyWorkPhone As String, _
        ByVal strEmergencyWorkPhoneExt As String, _
        ByVal strEnteredBy As String)

        On Error GoTo ErrorTrap

        Dim cmd As New SqlCommand
        cmd.CommandText = "ps__employee_emergency_contacts_UPDATE_ContactInfo"
        cmd.CommandType = CommandType.StoredProcedure

        cmd.Parameters.AddWithValue("@ssn", strSSN)
        cmd.Parameters.AddWithValue("@emergency_relation", strEmergencyRelation)
        cmd.Parameters.AddWithValue("@emergency_name", strEmergencyName)
        cmd.Parameters.AddWithValue("@emergency_address", strEmergencyAddress)
        cmd.Parameters.AddWithValue("@emergency_city", strEmergencyCity)
        cmd.Parameters.AddWithValue("@emergency_state", strEmergencyState)
        cmd.Parameters.AddWithValue("@emergency_zipcode", strEmergencyZipCode)
        cmd.Parameters.AddWithValue("@emergency_apartment", strEmergencyApartment)
        cmd.Parameters.AddWithValue("@emergency_phone", strEmergencyPhone)
        cmd.Parameters.AddWithValue("@emergency_work_phone", strEmergencyWorkPhone)
        cmd.Parameters.AddWithValue("@emergency_work_phone_ext", strEmergencyWorkPhoneExt)
        cmd.Parameters.AddWithValue("@entered_by", strEnteredBy)

        Dim cnn As New Connection
        cnn.OpenConnection()
        cmd.Connection = cnn.GetConnection
        cmd.ExecuteNonQuery().ToString()
        cnn.CloseConnection()

ErrorTrap:
        Err.Raise(Err.Number, "Personnel.EmployeeEmergencyContactsUpdate > " & Err.Source, Err.Description)
        On Error GoTo 0
    End Sub

SP----------------------------------

CREATE PROCEDURE [dbo].[ps__employee_emergency_contacts_UPDATE_ContactInfo]
(
@ssn					char(11),
@emergency_relation			char(2),
@emergency_name				varchar(36),
@emergency_address			varchar(36),
@emergency_city				varchar(20),
@emergency_state			char(2),
@emergency_zipcode			varchar(10),
@emergency_apartment		        varchar(4),
@emergency_phone			varchar(12),
@emergency_work_phone		        varchar(12),
@emergency_work_phone_ext	        varchar(7),
@entered_by				char(7)
)
AS
UPDATE employee_emergency_contacts
SET	emergency_relation = @emergency_relation,
	emergency_name = @emergency_name,
	emergency_address = @emergency_address,
	emergency_city = @emergency_city,
	emergency_state = @emergency_state,
	emergency_zipcode = @emergency_zipcode,
	emergency_apartment = @emergency_apartment,
	emergency_phone = @emergency_phone,
	emergency_work_phone = @emergency_work_phone,
	emergency_work_phone_ext = @emergency_work_phone_ext,
	entered_by = @entered_by
WHERE
	ssn = @ssn
ASKER CERTIFIED SOLUTION
tomnorra

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros