Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Multiple forms and a DataSet
 

Multiple forms and a DataSet

Hi

I'm making a application that allow easy adminsitration of a databas. The application consists of one main form and a number of smaller froms. My problem is how to design it so that all the forms can use the same DataSets/DataViews. What is the best way of doing it?

For the moment I have all my Data-related objects in the Main Form. That, of cource, leads to difficulties when trying to reach and edit the information in the smaller forms. I have though about creating a middlelayer between the forms and the database containing all DataSets and such as well as the DataAdapters and update logic. This I thing would be a nice solution well in line with the object oriented paradigm. 

Another approach would be to crate a DataHolder class that just keeps all DataSets/DataAdapters and so on. But they will be created and executed in the forms. 

Suggestions?
MigrationUser 1  Wednesday, September 24, 2003 6:48 AM
Well you can pass the reference of the datatable to the second form

create a variable on the second form like so

public _DS as dataset 'note I didn't put new


then when you open the second form you pass the dataset

dim f as new secondform
f._ds = mydataset
f.show()

this will alow the second form to edit the dataset from the first, since you are just passing the reference to the same object.

Hope this helps.

Joe
MigrationUser 1  Monday, October 20, 2003 10:03 AM
Thanx for your answer. 

But I went with the approach of creating a component class that's declared as a singleton. Than all my forms gets an instance of that class and in that way I'm certain that all forms manipulate the same data.


MigrationUser 1  Tuesday, October 21, 2003 2:19 AM

You can use google to search for other answers

Custom Search

More Threads

• UserControl problem...
• Visual Studio just trashed my toolstrips!!
• URGENT: load form err w/UserControl, VS 2005, "Could not find type <xxx>..."
• Windows custom Control imported into asp.net web page
• Using SplitContainer in MDI Form.
• Deleting a DataBinding
• using WinFX for a Vista Look??
• How I Make a form a Resolution Independent Form?
• status strip trouble: cant find status panel
• Form Designer Blank