dataset dispose slowing form down

divjoy

Well-known member
Joined
Aug 25, 2013
Messages
159
Programming Experience
1-3
Hi,

Im using vb.net 2010 express and have a form with the folowing

Public Class frmViewClients
'..Show Area Clients and their ...
Dim Ans As String = ""
Dim bs, bs1, bs2 As New BindingSource
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim conn As New SqlClient.SqlConnection(connStr)


just added the following code to my 'close form' event.

'...Close View Client Form and Show Main Menu Form
frmMainMenu.Show()
Me.bCloseFormNow = True
Me.da.Dispose()
Me.ds.Relations.Remove(ds.Relations("RelClientsStaff"))
Me.ds.Tables.Clear()
Me.ds.Dispose()
Me.bs.Dispose()
Me.bs1.Dispose()
Me.bs2.Dispose()
Me.Close()

The code open the Main Menu form, dispose of data adapter da, remove relation, clears talbes and dispose of dataset ds and three binding sources bs, bs1, bs2

It works OK, but has now created a delay opening the frmMainMenu.

Is all this disposing really necessary? IS there a quicker way to do it
 
Back
Top