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 6477673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:58:38+00:00 2026-05-25T06:58:38+00:00

I’m getting an error in my VB.NET application that connects to my SQL database.

  • 0

I’m getting an error in my VB.NET application that connects to my SQL database. It connects fine, but for some reason I can’t fix this error. When I try to fix it, it moves from one part of my script to another part of my script (both of which were working yesterday). The error details are:

Error

Unfortunately, it’s difficult for me to describe how I produced this result, because it has happened in multiple parts of my code, and the only thing that these parts have in common is their interaction with Listbox1.

The first part of code to get this error was:

Dim sqlpage As MySqlCommand = New MySqlCommand("SELECT * FROM [" & frmMain.ListBox1.SelectedItem.value & "]", con)

Then I got the same exact error for:

Private Sub ListBox1_SelectedValueChanged( _
    ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles ListBox1.SelectedValueChanged

    Try
        Form1.Label1.Text = ListBox1.SelectedItem
        Form1.Show()
    Catch myerror As MySqlException
        MessageBox.Show("Error Setting Up Project Page: " & myerror.Message)
    End Try
End Sub

More specifically:

Form1.Label1.Text = ListBox1.SelectedItem

And then I got it a few more times, but I think the examples above will suffice.

Since there are no “With Block Variables” in the examples above then the only other option is that it’s object related. I’ve tried different methods of defining and redefining the object variables related to the error. However, the results are the same.

In response to Juxtaposition’s answer, my original problem has been solved however two new problems have come up specifically because I turned Option Strict on.

  • The first is:

Error1: Option Strict On disallows late binding.

The code in question is:

Try
    ' Retrieving the projects list.
    con.Open()
    DataAdapter2.SelectCommand = sqlprojects
    DataAdapter2.Fill(ds2, "projects")
    ListBox1.Items.Clear()

    For Each DataRow In ds2.Tables("projects").Rows

        ' Error occurs on the line below
        ListBox1.Items.Add(DataRow("project_name"))
    Next
    con.Close()

Catch myerror As MySqlException
    MessageBox.Show("Error Retrieving Projects List: " & myerror.Message)
End Try
  • The second is:

Error 2: Option Strict On disallows implicit conversions from ‘Object’ to ‘String’.

The code in question is:

Private Sub ListBox1_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedValueChanged

    Try
        If ListBox1.SelectedItem IsNot Nothing Then

            ' Error occurs on the line below
            Form1.Label1.Text = ListBox1.SelectedItem
        End If

        Form1.Show()
    Catch myerror As MySqlException
        MessageBox.Show("Error Setting Up Project Page: " & myerror.Message)
    End Try
End Sub

It worked out… so I thank all of you for your time and patience.

  • 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-25T06:58:39+00:00Added an answer on May 25, 2026 at 6:58 am

    Focus on this line for the moment:

    Form1.Label1.Text = ListBox1.SelectedItem
    

    If you’re getting a NullReferenceException on this line, then one of the following has to be true:

    • Form1 is null
    • Form1.Label1 is null
    • ListBox1 is null

    You can try to determine this by adding lines like these just before the above line:

    Console.Writeline("Form1: " & (Form1 Is Nothing))
    Console.Writeline("Form1.Label1: " & (Form1.Label1 Is Nothing))
    Console.Writeline("ListBox1:" & (ListBox1 Is Nothing))
    

    You should see a line that outputs true; that’s the first clue. But then the next question is, why is it null? From what you’ve shown so far, I can’t say.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace

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.