I have a form load sub routine here and the problem is that the program executes the first one (namely, LoadProgrammes()
) and then skips the rest of the subroutine. There is something about the subroutine LoadProgrammes()
that makes the rest of "Form Load" not get called.
The same goes for ListActiveClasses()
. Only DisplayGroups()
is called properly and the next line of code is called.
I literally have no idea why and it is extremely difficult to find a google solution. Thanks in advance to whomever can help.
Private Sub frmEnroll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadProgrammes()
ListActiveClasses()
DisplayGroups()
End Sub
Private Sub LoadProgrammes()
Dim strLoadSQL As String
Dim dsLoad As New DataSet
Dim daLoad As OleDb.OleDbDataAdapter
Using con As New OleDbConnection(My.Settings.ConnectionPath)
strLoadSQL = "SELECT Programme FROM Programmes"
daLoad = New OleDb.OleDbDataAdapter(strLoadSQL, con)
daLoad.Fill(dsLoad, "LoadProgrammes")
'Add items to the combobox
For i = 0 To dsLoad.Tables("LoadProgrammes").Rows.Count
cmbProgramme.Items.Add(dsLoad.Tables("LoadProgrammes").Rows(i).Item(0))
Next
End Using
End Sub
What I have seen, is that in some event handlers (maybe like your Form.Load handler), any exception that is thrown during execution will simply be swallowed, and ignored. Most likely you are getting some exception in your OleDb code, that is causing it to bail out.
I would recommend wrapping all of your _Load subroutine with a Try...Catch block, and manually printing out the exception, or calling Debugger.Break.
Have you tried stepping through the code? I would recommend that you set a breakpoint at the beginning of
frmEnroll_Load
, and start stepping through until something blows up, or the code just continues (which is what you would see if the exception was getting swallowed.)Related questions / pages: