Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can two forms work with the same dataset ?

Status
Not open for further replies.

anrver

Programmer
Jun 24, 2002
12
0
0
CH
I'm just starting with VB.net.
I have a form with an overview of all my customers and I have a second form for the entry and edit of a customer.
I made it possible to click on a customer that is listed on the first form to open the second form. I believe that in this case the dataset of my customers will be openend by each form and will be placed two times in memory. As i have a large customer table I don't wont to do that. Is there a way that both forms can work on the same dataset and how do I do this ?

Erik Verstichel
Panalpina World Transport.
Antwerp, Belgium
 
Yes.
I see 2 options:
1) Declare your dataset as 'public' and hand a reference to the instance of your main form when you open the 'child form'. In this way you can access the dataset through the reference: ObjMainForm.YourDataSet (you should probably show the 'child' form modally so things don't get messed up).
2) Declare your dataset as 'Public Shared' in which case it will alwasy be available through the class type name: MainForm.SharedDataSet.

Notice that 1) uses a reference to an instance of the class, whereas 2) can access the variable through the class name itself because the variable is declared as shared.


Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Ok, I will try out both solutions.
Many Thanks

Erik Verstichel
Panalpina World Transport.
Antwerp, Belgium
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top