-
Feb 13th, 2013, 04:12 PM
#1
Thread Starter
Lively Member
One project, one Database but multiple forms.
I have a fairly simple question (I guess): If I have one project that connects to only one database(Access) with one table, but in my project I have 3 forms. One for displaying and filtering data(datagridview). One for editing(detail view with textboxes) and one for adding data(detail view with textboxes).
How should I set up dataadapters and datasets(should I use existing dataset or create new). Do I have to set them up on every form independently or what? What is the best practice for this kind of situation?
-
Feb 13th, 2013, 04:28 PM
#2
Re: One project, one Database but multiple forms.
Are you adding tables etc. at design time or dynamically?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 13th, 2013, 04:34 PM
#3
Thread Starter
Lively Member
Re: One project, one Database but multiple forms.
Originally Posted by dunfiddlin
Are you adding tables etc. at design time or dynamically?
What is the difference between them?
Let's say I want to add tables etc. at design time...
Sorry, I am still learning the secrets of databases and vb.
-
Feb 13th, 2013, 04:43 PM
#4
Re: One project, one Database but multiple forms.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 13th, 2013, 04:50 PM
#5
Re: One project, one Database but multiple forms.
You should only have one dataset, if you are going to have a dataset for this (you don't HAVE to, but you probably do need to). If you don't do it that way, then each form would have to open the connection, get the data into their own dataset, then close the connection. You might then make changes on form A, but form B wouldn't know about those changes, because it has a different view of the data, so once form A was done, form B would have to go back to the database and refresh its information.
A better design would be to have one dataset that all forms share. Any changes made by form A would be instantly seen by form B, because they would be sharing the dataset. You could then make as many changes as you wanted to, by whichever form you felt should make the changes, and only when you are ready would you push those changes back to the database.
My usual boring signature: Nothing
-
Feb 13th, 2013, 05:02 PM
#6
Thread Starter
Lively Member
Re: One project, one Database but multiple forms.
Originally Posted by dunfiddlin
Ok, I misunderstood you. Design time = with wizard and dynamically=programmatically. Yes, I have studied these tutorials already.
Unfortunately these tutorials didn't answer my question that I brought up in post 1.
-
Feb 13th, 2013, 05:14 PM
#7
Frenzied Member
Re: One project, one Database but multiple forms.
Originally Posted by lkallas
I have a fairly simple question (I guess): If I have one project that connects to only one database(Access) with one table, but in my project I have 3 forms. One for displaying and filtering data(datagridview). One for editing(detail view with textboxes) and one for adding data(detail view with textboxes).
How should I set up dataadapters and datasets(should I use existing dataset or create new). Do I have to set them up on every form independently or what? What is the best practice for this kind of situation?
Kind of up to you. You could do it inline whenever you needed to access the database. You could make a class you reference from all of them. You could make a class you instantiate an instance of in all of them. Really up to you. Not sure there is really a right or a wrong way.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Feb 13th, 2013, 05:31 PM
#8
Re: One project, one Database but multiple forms.
Design time data objects can be accessed like this ... Form1.SomeBindingSource
If you're creating a Dataset dynamically then declare it thus ... Public DBSet As DataSet ... and all tables associated with the dataset are available from all forms. DataAdapters, however should always be declared separately in every Sub in which they are used.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|