Solved Coding Problem

Posted on 2011-10-11
Last Modified: 2012-05-12
I have this set of VB code which fails if there is no data retrieved for a record in SQL.  It calls an:

Object reference not set to an instance of an object.  

The data(0) is an array and it works fine if their is data, but throws the error if the data is blank.  How can I wrap an is nothing clause around this code to prevent errors from throwing if the data array is nothing.

            Dim Cube_height As Exact.Web.UI.Controls.InputField
            Cube_height = BuildFields.BuildInputField("CSItemscube_height", False, Data(0), "", False)
Question by:red_75116
    LVL 38

    Expert Comment

    by:Tom Beck
    You could try wrapping it in an IsDBNull conditional.

    If Not IsDBNull(Data(0)) Then


    End If
    LVL 38

    Accepted Solution

    The other possibility is that if the array has been initialized but not being populated with data then you could check this way:

    If Not Data Is Nothing Then

    '''do something with the data

    End If

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now