locked
Error on ArrayList RRS feed

  • Question

  • User1602246193 posted

    Hi all,

    In my code, I want to use ArrayList to store some data but I get the runtime error says "Object reference not set to an instance of an object." Anyone know how to fix it? Thanks in advance.

            Dim dtrJobs As SqlDataReader
            dtrJobs = sqlCmd.ExecuteReader()

            While dtrJobs.Read()
                If dtrJobs("msg_tonum").ToString <> "" Then
                    number.Add(dtrJobs("msg_tonum"))   //got error here
                End If

             End While

    Wednesday, April 30, 2008 6:36 AM

Answers

  • User1564875471 posted

    there is 2 possible reasons for that :

    • the SQl data reader doeasn't contains "msg_tonum" column .
    • the array list is not declared using new , e.g. dim number as new arrylist

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 30, 2008 7:32 AM

All replies

  • User1564875471 posted

    there is 2 possible reasons for that :

    • the SQl data reader doeasn't contains "msg_tonum" column .
    • the array list is not declared using new , e.g. dim number as new arrylist

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 30, 2008 7:32 AM
  • User1602246193 posted

    Thanks Anas,

    Wednesday, April 30, 2008 7:40 AM