All,

I created a VB.NET web application project. Recently I got the dreaded above error message when a certain amount of web pages have loaded. On a form1_Load event, I do this:

vb Code:
  1. Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
  2.         '
  3.         MyConnection = New SqlConnection
  4.         MyConnection.ConnectionString = CONN_STRING
  5.         MyConnection.Open()
  6.         '
  7.         Me.GridView1.Sort("Priority", SortDirection.Ascending)
  8.         '
  9.     End Sub

Question: Am I required to explicitly call the .Close? Inside which event would be the appropriate place?

Will this do the trick - or break anything?

vb Code:
  1. Protected Sub form1_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Unload
  2.         MyConnection.Close()
  3.         MyConnection = Nothing
  4.     End Sub

Thanks!

Dave