Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:56:05+00:00 2026-05-22T14:56:05+00:00

I can’t seem to figure out why the below code is giving me the

  • 0

I can’t seem to figure out why the below code is giving me the following error:

Object reference not set to an instance of an object.
Line 47:             objSQLCommand.Connection.Open()

This is the problem code:

Function getTabContent() As String
    Dim strUserInitials() As String = Request.ServerVariables("LOGON_USER").Split(CChar("\"))
    strUser = LCase(Trim(strUserInitials(strUserInitials.GetUpperBound(0)))).ToString()

    objStringBuilder = New StringBuilder()

    For intColumn As Integer = 1 To 3
        objSQLCommand = New SqlCommand("select c.*, w.* " & _
        "from intranet.dbo.tabs t " & _
        "inner join intranet.dbo.columns c on t.id = c.tabs_id " & _
        "inner join intranet.dbo.widgets w on c.widgets_id = w.widget_id " & _
        "where t.is_default = 0 " & _
        "and t.cms_initials = @user " & _
        "and t.id = @tab " & _
        "and c.sort_column = @column " & _
        "and w.inactive = 0 " & _
        "order by c.tabs_id, c.sort_column, c.sort_row", objSQLConnection)

        objSQLCommand.Parameters.Add("@user", SqlDbType.VarChar, 3).Value = strUser
        objSQLCommand.Parameters.Add("@tab", SqlDbType.Int, 4).Value = Request.QueryString("tab")
        objSQLCommand.Parameters.Add("@column", SqlDbType.Int, 4).Value = intColumn

        objStringBuilder.Append("<div class=""column"" id=""column_" & intColumn & """>")

        objSQLCommand.Connection.Open()
        objSQLDataReader = objSQLCommand.ExecuteReader()

        While objSQLDataReader.Read()
            objStringBuilder.Append("<div class=""portlet"" id=""portlet_" & objSQLDataReader("widget_id") & """>")
            objStringBuilder.Append("<div class=""portlet-header"">" & objSQLDataReader("widget_name") & "</div>")
            objStringBuilder.Append("<div class=""portlet-content"">" & objSQLDataReader("widget_description") & "</div>")
            objStringBuilder.Append("</div>")
        End While

        objSQLDataReader.Close()
        objSQLCommand.Connection.Close()

        objStringBuilder.Append("</div>")
    Next intColumn

    Return objStringBuilder.ToString
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:56:06+00:00Added an answer on May 22, 2026 at 2:56 pm

    The problem appears to be that the Connection property on objSqlCommand is Nothing and hence you get a NullReferenceException when you access it. This means in all likely hood that objSqlConnection is also Nothing and that is likely the root cause of your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
Can you set the internal [[Class]] property of an ECMAScript object?
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can anyone give me an example of how to return the following json simply
Can someone maybe tell me why this is not working? I have used echo
Can I be notified of the following events for an Activity: screenSizeWillChange screenSizeDidChange I
Can some one confirm me that only one UIWindow instance is possible in any
Can i get the source code for a WAMP stack installer somewhere? Any help
can anyone tell me if it is possible to convert a dojo charting object
Can't work out a way to make an array of buttons in android. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.