Ever Since Last Windows 10 Update Getting System.NullReferenceException: 'Object reference not set to an instance of an object.' RRS feed

  • Question

  • Ever since the last Windows 10 update, the following code:

     Dim conn1 As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & txtFileLocDB.Text & ";Persist Security Info=True")
            Dim strDGVOld_Resub As String = "SELECT * FROM [OLD_RESUB_PARCELS]"
            Dim dsDGVOld_Resub As New DataSet()
            Dim adDGVOld_Resub As New System.Data.OleDb.OleDbDataAdapter(strDGVOld_Resub, conn1)
            Dim rowid2 As Integer = 0
            Dim rowpos As Integer = 0

            adDGVOld_Resub.Fill(dsDGVOld_Resub, "OLD_RESUB_PARCELS")
            TextBox1.Text = dsDGVOld_Resub.Tables("OLD_RESUB_PARCELS").Rows.Count.ToString
            dgvOld_Resub.DataSource = dsDGVOld_Resub.Tables("OLD_RESUB_PARCELS")


    Where dgvOld_Resub is the datagridview on my form.

    I now get the error:


    The dataset is populated by the database table verified by textbox1 showing there are 322 records.  The datagridview shows the 1st record and then throws the above error.  It runs all of the code before this just fine.  Very frustrating since I've been using this app for years now and all of a sudden it just stops working.  I've been trying to figure this out for 3 days now.  What am I missing?  Any help is greatly appreciated.

    Friday, May 17, 2019 5:00 PM

All replies

  • Did you determine the line or event handler that produces this error? If it is not clear, then maybe press “View Details” and investigate Call Stack and other details.

    Friday, May 17, 2019 6:35 PM
  • View details just says that an exception was thrown with no real details.  However I do believe that this is the line that is tripping this error:

    dgvOld_Resub.DataSource = dsDGVOld_Resub.Tables("OLD_RESUB_PARCELS")

    Never really got down to the bottom of this issue.  I don't have any idea why it started doing this other than it coincides with the latest updates from Windows 10.  I found a work around by creating another subroutine called FillDGVOldResub with the code above.  I then had to set FillDGVOldResub to run before the other subroutine that contains the rest of the code when the start button is clicked.  I never came across this issue before.  Curious to hear if anyone else has any ideas on what may have caused this.

    • Edited by theneogen Friday, May 17, 2019 7:42 PM
    Friday, May 17, 2019 7:28 PM
  • Hello,

    You can try the following.

    Dim Items As DataTable = dsDGVOld_Resub.Tables("OLD_RESUB_PARCELS")
    Console.WriteLine("Put a breakpoint here")

    Put a breakpoint on the last line, when hit hover over the line above. If you never make it to Console.WriteLine then either the DataSet is not set of the table OLD_RESUB_PARCELS is not setup.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Friday, May 17, 2019 10:09 PM
  • Thank you for the reply.  I'll give that a try once I complete my current projects.  Priorities and deadlines constantly change in this job.
    Monday, May 20, 2019 12:45 PM