CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • object reference not set to an instance of an object

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    7267
  • Date Created
    Tuesday, August 1, 2023
  • This Article Has been Viewed
    639 times
  • Short Desc
    If the sqlcommand name is not the same for the parameters you will receive the following error, 'object reference not set to an instance of an object'.
  • Details
    If the sqlcommand name is not the same for the parameters you will receive the following error.

     
    object reference not set to an instance of an object
  • Recreate Issue
    The following command will cause this issue.

    Dim chTable As New SqlCommand("SELECT top 1 ISID from Table", con)
    chOneTable.Parameters.Add(New SqlParameter("@ID", theID))


    As you can see above, the chOneTable from the bottom is not the same as the top, chTable.
  • Resolve Issue
    To correct this issue we need to make sure our SQL Command is the same.

    Dim chTable As New SqlCommand("SELECT top 1 ISID from Table", con)
    chTable.Parameters.Add(New SqlParameter("@ID", theID))