Skip to content

Unable to debug Null reference Exception

Veeraragahvan Thirumale

Asked Feb 19, 2008, 1:14 AM EST1 answer
Share
LinkedInX
Hello all,
    I am am having a strange problem. I am  getting a null  reference  exception  error while retrieving data. the code is as follows:
key = Convert.ToInt64(e.KeyChar)
        Try
            If key = 13 Then
                If cmbName.Text = "" Then
                    MsgBox("Please Enter the Provider name", MsgBoxStyle.Information, "ITAC")
                End If
                con.Open()
                DbCmd = New MySqlCommand("Select IFNULL(currentST,0),IFNULL(UnpaidST,0),IFNULL(TotalST,0),IFNULL(HigherCess,0),IFNULL(PaymentsReceived,0),IFNULL(LowerCess,0),IFNULL(TaxableValue,0),IFNULL(SetoffValue,0) from MonthlyReports where Month='" & txtMon.Text & "' and Name='" & cmbName.Text & "'", con)
                DbReader = DbCmd.ExecuteReader
                If DbReader.Read Then
                    txtCurrentST.Text = DbReader.GetDecimal(0)
                    txtPreviousST.Text = DbReader.GetDecimal(1)
                    txtTotalST.Text = DbReader.GetDecimal(2) ' I am getting the error here
                    txtHigherCess.Text = DbReader.GetDecimal(3)
                    txtPaymentReceived.Text = DbReader.GetDecimal(4)
                    txtLowerCess.Text = DbReader.GetDecimal(5)
                    txtTaxableValue.Text = DbReader.GetDecimal(6)
                    txtSetOff.Text = DbReader.GetDecimal(7)
                Else
                    MsgBox("No transactions wree made for this month", MsgBoxStyle.Information, "ITAC")
                End If
                con.Close()
            End If
        Catch ex As NullReferenceException
            MsgBox(ex.Message)
        End Try

Here  I am trying to retrieve the data through key pree event
Your help would be highly appreciated
Thanks

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I found a solution for this problem. We have to Clear the textboxes before  invoking this procedure or this part of code I have displayed.
    0