1

I searched for similar issues, but none of them seem to help out this situation. I'm using Visual Basic .NET and connecting through SQL. I'm getting the error above, but only when I'm running the project through executable. In Debug mode, I am not getting the error.

I've narrowed it down to errors:

System.NullReferenceException: Object reference not set to an instance of an object. at APP_XIFIN.NET_3._5.WebServices.Execute()

Then:

System.InvalidCastException: Conversion from string "JAV" to type 'Double' is not valid. ---> System.FormatException: Input string was not in a correct format. at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) --- End of inner exception stack trace --- at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value) at APP_XIFIN.NET_3._5.XIFIN_Global.EndTransmission(String AccessionID, String Sequence, String StatusCode, String StatusMessage, String RefDate)

What confuses me the most of that nothing in either the database nor in the code is related to a Double.

Here's the code:

Public Function EndTransmission(ByVal AccessionID As String, ByVal Sequence As String, ByVal StatusCode As String, ByVal StatusMessage As String, Optional ByVal RefDate As String = "NO") As Date

UPDATE TransmissionQueue SET StatusCode = @StatusCode, StatusMessage = @StatusMessage, InterfaceTime = GETDATE(), ReferencesBuiltTime = GETDATE() WHERE AccessionID = @Accession AND Sequence = @Sequence"

    Try
        Using connection As New SqlConnection(connectionstring)
            connection.Open()
            Using Command As New SqlCommand(sql, connection)

                'set parameters
                Command.Parameters.Add("@StatusCode")
                Command.Parameters("@StatusCode").Value = StatusCode

                Command.Parameters.Add("@StatusMessage")
                Command.Parameters("@StatusMessage").Value = StatusMessage

                Command.Parameters.Add("@Accession")
                Command.Parameters("@Accession").Value = AccessionID

                Command.Parameters.Add("@Sequence")
                Command.Parameters("@Sequence").Value = Sequence

                'execute
                Command.ExecuteScalar()
            End Using
            connection.Close()
        End Using
   End Using

    Catch ex As Exception
        'A connection level error has occurred
        'Expand exception handling as needed
        'MsgBox(ex.ToString) 'Convert this to Windows Event Log
        Call SendEmail(ex.ToString, "Accession: " & AccessionID & vbNewLine & "Sequence: " & Sequence & vbNewLine & "StatusCode: " & StatusCode & vbNewLine & "RefDate: " & RefDate)
    End Try

I've also tried this code:

sql = "UPDATE TransmissionQueue SET StatusCode = '" + StatusCode + "', StatusMessage = '" + cSQL(StatusMessage) + "', InterfaceTime = GETDATE(), ReferencesBuiltTime = GETDATE() WHERE AccessionID = '" + AccessionID + "' AND Sequence = '" + Sequence + "'"

    Try
        Using connection As New SqlConnection(connectionstring)
            connection.Open()
            Using Command As New SqlCommand(sql, connection)

                'execute
                Command.ExecuteScalar()
            End Using
            connection.Close()
        End Using
End Using

Any help is greatly appreciated.

Ray
  • 9
  • 3
  • What are the data types of the fields in your table? – Jim May 06 '15 at 23:55
  • 1
    Errors after the initial one (object reference not found) are probably irrelevant, because the code has already failed. You need to figure out which object doesn't exist. Show the actual stack trace that got you to the exception itself. (And read one of the hundred or so previous questions related to *object instance not found*, ten or so of which are linked in the **Related** list to the right of this question ====>>>> and which were displayed for you as you posted your question. Most (if not all) of them contain some debugging tips on how to track down the error's cause.) – Ken White May 06 '15 at 23:57
  • What's the line that throws the error? – SomeNickName May 07 '15 at 00:00
  • 1
    Nearly all NullReference Exceptions have the same set of causes. See [NullReference Exception in Visual Basic](http://stackoverflow.com/a/26761773/1070452) for help on this. Also *"only on one computer"* is not the same as *"only when running the ... executable"* – Ňɏssa Pøngjǣrdenlarp May 07 '15 at 01:41
  • Sorry, I should've provided this earlier. Accession = int Sequence = int Operation = char(1) Source = varchar(255) StatusCode = varchar(3) StatusMessage = varchar(4000)
    InterfaceTime = datetime ReferencesBuiltTIme = datetime No line is provided and I pasted everything the stacktrace error provides.
    – Ray May 07 '15 at 15:52
  • possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Ňɏssa Pøngjǣrdenlarp May 07 '15 at 17:35
  • Stack trace: System.InvalidCastException: Conversion from string "JAV" to type 'Double' is not valid. ---> System.FormatException: Input string was not in a correct format. at Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String Value, NumberFormatInfo NumberFormat) at Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(String Value, NumberFormatInfo NumberFormat) Oddly enough, there is no indication this is a double anywhere. – Ray May 14 '15 at 23:14

1 Answers1

0

Unfortunately the fix was not because of an issue on my end. I had a ticket open with the company I was transmitting data to and it resolved the issue.

Basically, last names and first names were stored in a single field on another table that was used to transmit the data. Their system did not support NULL values for either first name or last name. As a result, I built a SSIS job that would split the last name if it had a comma and update the table with the first name and last name.

The company is still looking into the issue on their end, but the fix on my end worked.

Problem solved!

Ray
  • 9
  • 3