Click here to Skip to main content
15,568,971 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I'm having some problem when running this code.

Can you please solve the run time error of "NullReferenceException" in following code which was generated

VB
Try
            NowTime = DateTime.Now
If IsValidShutdown Then
                tblRawTesterShutdown = objDAL.GetRawTesterShutdown(StartTime, NowTime)
asdasdIf tblRawTesterShutdown.Rows.Count > 0 Then
                    For Each RowItem As DataRow In tblRawTesterShutdown.Rows
                        objShutdownReport = New ShutdownReportENT
                        With objShutdownReport
                            .ShutdownType = _ShutdownType
                            .TesterID = LineNo                          
                            .E_Code = RowItem.Item("E_FIELD").ToString.Trim
                            .F_Code = RowItem.Item("F_FIELD").ToString.Trim
                            .G_Code = RowItem.Item("G_FIELD").ToString.Trim
                            .Status = RowItem.Item("HSA_STATUS").ToString.Trim
                            .Family = RowItem.Item("FAMILY").ToString.Trim
                            .Count = CInt(RowItem.Item("COUNTOFLINENO"))
                            .StartTime = StartTime
                            .Timestamp = NowTime                           
                            .CACHE_FAMILY = RowItem.Item("CACHE_FAMILY").ToString.Trim                           
                            If Family = Nothing Then
                                Family = "'" & .Family & "'"
                            Else
                                If Family.IndexOf(.Family) = -1 Then
                                    Family = Family & ",'" & .Family & "'"
                                End If
                            End If
                        End With

                        objDAL.InsertShutdownReport(objShutdownReport)
                    Next
                Else
                    Return False
        End If
 Catch ex As Exception
            Throw New Exception("Shutdown: " & ex.Message)
        Finally
        End Try
        Return False
Posted
Updated 3-Apr-13 18:37pm
v3
Comments
Karthik Harve 4-Apr-13 0:09am    
did you debug the code ? did you found the line of code throwing this error ? usually, this error comes, when objects went null and you trying to access it. debug and find the which object is that and try to fix it.
kumar2413 4-Apr-13 1:48am    
I have done the debug actually and manage to find the error. Thanks a lot for your help and guidance.
Karthik Harve 4-Apr-13 1:54am    
Can you tell us which line of code throwing this error ? because, this error may cause by any of the objects in your code.
kumar2413 4-Apr-13 3:05am    
No actually there is continues code below that when i modify that then it able to work. because the down part only was having some problem.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900