tableadaptor with Multiple Tabs

sullyman

Active member
Joined
Nov 11, 2009
Messages
37
Programming Experience
Beginner
Just a quick question for a noob on grids stored in seperate tabs.

If a user is working on Tab1 and makes changes to Gridview1 on Tab1 and then saves entries/updates using update tableadaptor etc and then proceeds to Tab2 where another Gridview(2) for data entry is present, is the connection to Gridview1 tableadaptor/dataset data still open in anyway on Tab1.

If the connection is still open, does this use memory resources. Is there a way to close the tableadaptor connection to gridview1 when moving to tab2 etc. or am i talking ****e :)
 
Unless you close it, it is open and if it is open it is using resources.

I don't, and have never, use tableadapters, but I'm sure they can be closed as easily as they are open.
 
Thanks for reply. I am filling the gridview with the following command using Devexpress.com gridview tools etc.

Me.DataTableAdapter.Fill(Me.DsData.DataEntries)

So i am unsure how to close the connection if it is open on moving to tab2
 
There's no connection whatsoever between your grid and/or other controls and your TableAdapter. The controls are all about displaying data to the user and allowing the user to edit that data. The TableAdapter is about retrieving data from the database and saving changes to the database.

When you call Fill or Update on your TableAdapter it will open the database connection, save the data and then close the database connection. There is no need for you to worry about opening and closing connections manually when using TableAdapters. In fact, they are just wrappers for a DataAdapter anyway, and calling Fill and Update on a DataAdapter will also automatically open and close the connection.
 
If the connection is still open, does this use memory resources. Is there a way to close the tableadaptor connection to gridview1 when moving to tab2 etc. or am i talking ****e :)

TAs open and close connections as needed, generally following the rule "alter it to do your work, but leave it how you found it"

Your app (.net itself) will maintain connections to the database itself. This is called Connection Pooling and is for performance reasons. You should have a good idea of what youre doing, what its doing and the reasons behind switching it off before you attempt to do so. You have no control over the pooling; dont try to exert any.
 
Back
Top