TheMadHater
Programmer
Hello all,
I getting this error "Object reference not set to an instance of an object." when I hit the next button on my form all code is below Visual Studio 2008 express, sql express. controls are bound to a data set. The form loads and the first record is displayed but there are two issues.
1. The lblPosition doesn't display any information after the load
2. When I use the button click event I get the above referenced error. "Object reference not set to an instance of an object.
Can anyone shed any light on this? I have reason to believe that the error is generated somewhere on this line.. artists is the database name.
bmbArtists = Me.BindingContext(DsArtistDisplay1, "artists")
Public Class Form1
Inherits System.Windows.Forms.Form
Dim bmbArtists As BindingManagerBase
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DsArtistDisplay1.DataTable1' table. You can move, or remove it, as needed.
DataTable1TableAdapter.Fill(DsArtistDisplay1.DataTable1)
'bmbArtists = Me.BindingContext(DsArtistDisplay1, "artists")
DisplayPosition()
End Sub
Private Sub DisplayPosition()
lblPos.Text = bmbArtists.Position + 1 & "of" & bmbArtists.Count
End Sub
Private Sub NavigationButtons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click, btnLast.Click, btnNext.Click, btnPrevious.Click
Select sender.name
Case "btnFirst"
bmbArtists.Position = 0
Case "btnLast"
bmbArtists.Position = bmbArtists.Count - 1
Case "btnNext"
bmbArtists.Position += 1
Case "btnPrevious"
bmbArtists.Position -= 1
End Select
DisplayPosition()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
End Class
I getting this error "Object reference not set to an instance of an object." when I hit the next button on my form all code is below Visual Studio 2008 express, sql express. controls are bound to a data set. The form loads and the first record is displayed but there are two issues.
1. The lblPosition doesn't display any information after the load
2. When I use the button click event I get the above referenced error. "Object reference not set to an instance of an object.
Can anyone shed any light on this? I have reason to believe that the error is generated somewhere on this line.. artists is the database name.
bmbArtists = Me.BindingContext(DsArtistDisplay1, "artists")
Public Class Form1
Inherits System.Windows.Forms.Form
Dim bmbArtists As BindingManagerBase
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DsArtistDisplay1.DataTable1' table. You can move, or remove it, as needed.
DataTable1TableAdapter.Fill(DsArtistDisplay1.DataTable1)
'bmbArtists = Me.BindingContext(DsArtistDisplay1, "artists")
DisplayPosition()
End Sub
Private Sub DisplayPosition()
lblPos.Text = bmbArtists.Position + 1 & "of" & bmbArtists.Count
End Sub
Private Sub NavigationButtons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click, btnLast.Click, btnNext.Click, btnPrevious.Click
Select sender.name
Case "btnFirst"
bmbArtists.Position = 0
Case "btnLast"
bmbArtists.Position = bmbArtists.Count - 1
Case "btnNext"
bmbArtists.Position += 1
Case "btnPrevious"
bmbArtists.Position -= 1
End Select
DisplayPosition()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
End Class