title: An unhandled exception of type 'System.NullReferenceException' occurred in Pipe Vault.exe
body: <p>This code for my Commit button was working most of the time yesterday the way that it is written below. Yesterday I periodically would get this exception, but today I get it everytime. Its failing on:</p>
  
  <p>Dim newRow As DataRow = ds.Tables("PV_Table").NewRow()</p>
  
  <p>It's saying newRow is Nothing, how can I fix this and what should it be?</p>
  
  <pre><code>Private Sub btnCommit_Click(sender As Object, e As EventArgs) Handles btnCommit.Click
  
  
      Dim newRow As DataRow = ds.Tables("PV_Table").NewRow()
      Dim cb As New OleDb.OleDbCommandBuilder(da)
      cb.QuotePrefix = "["
      cb.QuoteSuffix = "]"
  
      newRow("Location") = txtLocation.Text
      newRow("Project Name") = txtProjectName.Text
      newRow("Pipe Date") = txtPipeDate.Text
      newRow("Pipe Number") = txtPipeNumber.text
      newRow("Pipe Size") = txtPipeSize.Text
      newRow("Aprox Footage") = txtAproxFootage.Text
      newRow("Install Date") = txtInstallDate.Text
  
      ds.Tables("PV_Table").Rows.Add(newRow)
      da.Update(ds, "PV_Table")
      Me.PV_TableTableAdapter.Fill(Me.PVdbDataSet.PV_Table)    'DataGridView Binding
  
      'SET UP THE PROVIDER
      dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
  
      'SET THE DATABASE AND WHERE THE DATABASE IS
      TheDatabase = "/PVdb.accdb"
      MyFolder = "C:\Pipe Vault"
      FullDatabasePath = MyFolder &amp; TheDatabase
  
      'SET THE DATA SOURCE
      dbSource = "Data Source = " &amp; FullDatabasePath
  
      'SET THE CONNECTION STRING
      con.ConnectionString = dbProvider &amp; dbSource
  
      'OPEN THE DATABASE
      con.Open()
  
      'STORE THE SQL STRING AND CONNECTION OBJECT TO THE DATA_ADAPTER
      sql = "SELECT * FROM PV_table"
      da = New OleDb.OleDbDataAdapter(sql, con)
      da.Fill(ds, "PV_Table")
  
      'Close THE DATABASE  '
      con.Close()
  
      'ENABLES TEXT BOXES
      For Each a In Me.Controls
          If TypeOf a Is TextBox Then
              a.Enabled = False
          End If
      Next
  
      'CLEARS CONTENTS OF TEXT BOXES
      txtLocation.Clear()
      txtProjectName.Clear()
      txtPipeDate.Clear()
      txtPipeNumber.Clear()
      txtPipeSize.Clear()
      txtAproxFootage.Clear()
      txtInstallDate.Clear()
  
      'SETS STATES OF BUTTONS
      btnCommit.Enabled = False
      btnAddNew.Enabled = True
      btnUpdate.Enabled = False
      btnDelete.Enabled = False
  
  
  End Sub
  </code></pre>
  
  <p>I found in my Form Load event that I had the same code under the Comment 'STORE THE SQL STRING AND CONNECTION OBJECT TO THE DATA_ADAPTER. It was all commented out. I uncommented them and it seems to be working again.</p>
  
  <pre><code>Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
      Me.PV_TableTableAdapter.Fill(Me.PVdbDataSet.PV_Table)
  
      'SET UP THE PROVIDER
      dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
  
      'SET THE DATABASE AND WHERE THE DATABASE IS
      TheDatabase = "/PVdb.accdb"
      MyFolder = "C:\Pipe Vault"
      FullDatabasePath = MyFolder &amp; TheDatabase
  
      'SET THE DATA SOURCE
      dbSource = "Data Source = " &amp; FullDatabasePath
  
      'SET THE CONNECTION STRING
      con.ConnectionString = dbProvider &amp; dbSource
  
      'OPEN THE DATABASE
      con.Open()
  
      'STORE THE SQL STRING AND CONNECTION OBJECT TO THE DATA_ADAPTER
      sql = "SELECT * FROM PV_table"
      da = New OleDb.OleDbDataAdapter(sql, con)
      da.Fill(ds, "PV_Table")
  
  
      'Close THE DATABASE  '
      con.Close()
      'MessageBox.Show("Database is now closed")
  
  
      DataGridView1.GridColor = Color.Red
  
  
  
  
  
  End Sub
  </code></pre>