object reference not set to an instance of object

sef, If the problem is with Database return results, I presume it is in this scenario:

   dsData = getSQLData(conn,sql, blah,blah....)
   dt = dsData.Tables(0)  'Perhaps the obj ref not set is occurring here

To fix that:

  dsData = getSQLData(conn,sql, blah,blah....)
   If dsData.Tables.Count = 0 Then Exit Sub
   dt = dsData.Tables(0)  'Perhaps the obj ref not set is occurring here

edit: added code formatting tags …

Leave a Comment