with the information you've provided all anyone is going to be able to tell you is that the connection is closing unexpectedly. I would guess you're using C# since you posted in the C# forum but I could be wrong since you haven't even provided that much information.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...