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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

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
Jorge PaulinoIT Pro/DeveloperCommented:
I'm still waiting to see !
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

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
Jorge PaulinoIT Pro/DeveloperCommented:
Well you have 5 parameters and only four used in the code. Maybe the missing one is causing the error!
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.