• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

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

0
meteorelec
Asked:
meteorelec
  • 3
  • 3
1 Solution
 
jpaulinoCommented:
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
 
jpaulinoCommented:
I'm still waiting to see !
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now