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:
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load ' MyConnection = New SqlConnection MyConnection.ConnectionString = CONN_STRING MyConnection.Open() ' Me.GridView1.Sort("Priority", SortDirection.Ascending) ' 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:
Protected Sub form1_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Unload MyConnection.Close() MyConnection = Nothing End Sub
Thanks!
Dave




Reply With Quote