Parameters being passed to a stored procedure via an exe

What I'm doing is running an exe that will pass 5 parameters from a command line to the exe.  What I can do is to get these parameters to print out to notepad so I know that they are passing ok.  However when I pass them to the stored procedure it is returning an unhandled exception stating that it cannot insert a NULL value into the column USERID - this is relating to the Parameter in the stored procedure @USERCODE.  Does anyone have any suggestions, the stored procedure has not changed and I had this working before.  I've attached the code below.
Dim params() As String = Microsoft.VisualBasic.Command.Replace(", ", ",").Split(",")
        If params.Length >= 5 Then
 
            UserCode = params(0)
            AccountID = params(1)
            CampCallID = params(2)
            ContactID = params(3)
            Account = params(4)
 
        End If
 
        Dim connection As SqlConnection = _
        New SqlConnection("server=SALESLOGIX;Initial Catalog=slxlive;User Id=user;Password=password")
        connection.Open()
        Try
 
            Dim command As SqlCommand = _
           New SqlCommand("sysdba.sp_createpopact", connection)
            command.CommandType = CommandType.StoredProcedure
 
            command.Parameters.AddWithValue("@USERCODE", UserCode)
            command.Parameters.AddWithValue("@ACCOUNTID", AccountID)
            command.Parameters.AddWithValue("@CAMPCALLID", CampCallID)
            command.Parameters.AddWithValue("@CONTACTID", ContactID)
            command.ExecuteNonQuery()
 
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Throw
        Finally
            connection.Close()
        End Try
 
    End Sub

Open in new window

LVL 2
meteorelecAsked:
Who is Participating?
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
Well you have 5 parameters and only four used in the code. Maybe the missing one is causing the error!
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Can you show us the result of this:
            UserCode = params(0)
            AccountID = params(1)
            CampCallID = params(2)
            ContactID = params(3)
            Account = params(4)
 
0
 
meteorelecAuthor Commented:
Yeah I can show the results of all these parameters.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Jorge PaulinoIT Pro/DeveloperCommented:
I'm still waiting to see !
0
 
meteorelecAuthor Commented:
Sorry I'll sort it now, do you just want what I can output into notepad.
0
 
meteorelecAuthor Commented:
U0HOCA000002
test2AID
test3CID
test4ConID
test5ACC
 
This is what I can output to notepad to prove that it is passing the parameters from the command line, U0HOCA000002 is the Usercode, test2AID is the AccountID, test3CID is the CampcallID, test4ConID is the ContactID and test5ACC is the Account.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.