NullReferenceException

PeymaniuM

Member
Joined
Jul 17, 2006
Messages
22
Programming Experience
1-3
Hi Guys!
Well I have a DataGrid and each time any row is added or removed this method is called and it saves the data but when I want to delete the last row from this gridview it gives me NullReferenceException Error!

I searched everywhere but nothing I could find!
The only thing I noticed that I should put NEW keyword in this method but where and for which class I really dont know....This error was new for me, so thats why I send you this message!

This is my code:

Private Sub SaveData()
Dim TableAdapters As New DatabaseDataSetTableAdapters.PassnegerNamesTableAdapter
Me.TextBox1.Text = Me.RouteComboBox.SelectedValue
Me.TextBox2.Text = Me.FlightComboBox.SelectedValue
Me.TextBox3.Text = Me.TimeTextBox.Text
Me.TextBox4.Text = Me.DateTimePicker.Value
Try
Me.Validate()
Me.PassnegerNamesBindingSource.EndEdit()
TableAdapters.Update(
Me.DatabaseDataSet.PassnegerNames)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

I'm getting error right at this point!

Thanks
 
Last edited:
At which point? There's not really anything there that would throw an exception, I believe the error is occuring elsewhere. What is in the Me.Validate Sub? Also exactly what line is the exception being thrown?
 
Please read this link, the section about posting code:
http://www.vbdotnetforums.com/misc.php?do=bbcode

Note also, on these forums, the Advanced Editor mode can cause problems with code formatting when it tries to paste in coloured code (PublicSub vs Public Sub). To switch off the Advanced Editor, click the A/A button in the top right
 
Back
Top