Public Shared Dataset

M

Miro

I'm just trying to wrap something around my head and am looking for some
pro's vs con's on this scenario of what I am thinking of trying...

If someone with some experience with this could point me in the right
direction -

Lets say you have an MDI and 2 forms that open in that app.
Each form looks at the customer database but displays it differently.

If a customer gets added on form1, you would want it to instantly show up on
form2.
Same data - just displays the info differently.

So im assuming there are 2 options to do this:
1. on the MDI form, have a 'global' public shared dataset, so as a dataset
gets refreshed, it refreshes the new records instanlty on both
2. Keep track if the other form is open, if it is, and a refresh occurs on
this dataset, and its connection, refresh the other / shoot the one new
record over



Thanks,

Miro
 
C

Cowboy \(Gregory A. Beamer\)

You can do what you envision, and that should do well at keeping things up
to date. It is even better if you can have a controller farther up the stack
that will automatically refresh the forms when data changes. One option
there is the Smart Client Software Factory, which you can download for free.
Read through it first, as there is a learning curve and your app may not
warrant this much work. If you want to consider this route:

Information
http://www.codeplex.com/smartclient - documentation
http://msdn2.microsoft.com/en-us/library/aa480482.aspx - general
http://tinyurl.com/34797q - book (downloadable)

You can find all of the necessary bits on the www.microsoft.com/downloads
site. You need to install, for this to work:

..NET 3.0 (or 3.5 - Visual Studio 2008 works here)
Guidance Automation Extensions
Guidance Automation Toolkit
Composite Application Block
Visual Studio Extensions for .NET Framework 3.0
Smart Client Software Factory

The main download URL for the Smart Client Software Factory is here:
http://tinyurl.com/yv7m3n

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

*************************************************
| Think outside the box!
|
*************************************************
 
S

Steve Gerrard

Inline comments:
I'm just trying to wrap something around my head and am looking for
some pro's vs con's on this scenario of what I am thinking of
trying...
Lets say you have an MDI and 2 forms that open in that app.
Each form looks at the customer database but displays it differently.

If a customer gets added on form1, you would want it to instantly
show up on form2.

Yes I would.
Same data - just displays the info differently.

Yes, that makes sense.
So im assuming there are 2 options to do this:
1. on the MDI form, have a 'global' public shared dataset, so as a
dataset gets refreshed, it refreshes the new records instanlty on both

Something like that, yes. Add a record on a form 1, it will also show up on form
2, assuming you are using regular data binding.
2. Keep track if the other form is open, if it is, and a refresh
occurs on this dataset, and its connection, refresh the other / shoot
the one new record over

#2 is not as good. You don't need two connections, and you don't want to
duplicate the new record - it should only get saved once.

- - - - -

The real question, then, is, where to put your dataset for #1? You could keep it
on the main form, the MDI parent.

My preference is to create a class which will hold the dataset, along with a few
methods for working with it. A main app class, if you like. Then create one
instance of that class, and store it somewhere that is accessible throughout
your application.

While your main form will work, you might find that declaring a single public
variable in a module somewhere works better. (Gasp, a global variable? I say it
is okay for this purpose.) I like the idea of using the application events
module for this.
 
R

rowe_newsgroups

I'm just trying to wrap something around my head and am looking for some
pro's vs con's on this scenario of what I am thinking of trying...

If someone with some experience with this could point me in the right
direction -

Lets say you have an MDI and 2 forms that open in that app.
Each form looks at the customer database but displays it differently.

If a customer gets added on form1, you would want it to instantly show up on
form2.
Same data - just displays the info differently.

So im assuming there are 2 options to do this:
1. on the MDI form, have a 'global' public shared dataset, so as a dataset
gets refreshed, it refreshes the new records instanlty on both
2. Keep track if the other form is open, if it is, and a refresh occurs on
this dataset, and its connection, refresh the other / shoot the one new
record over

Thanks,

Miro

I would probably keep the dataset in the MDI parent, but preferably
not as a shared variable. Shared variables have a tendency of being
forgotten and sucking up memory, but as long as you are careful it
won't be a problem. I would probably then just fire off an event from
the child forms whenever a change has been made. This event would be
subscribed to by the mdi parent, and when it handles the event it
would know to update the dataset. Then, depending on how the forms
access the dataset, you might need another event to let the child
forms know that they need to redatabind. A second option, if you are
using Sql Server 2005 or later, would be to use the Sql Reporting
Services to notify your parent form whenever your data changes. Then,
the main form would know to update the dataset as well as force the
child forms to update. I've not used the Sql Reporting Services, so I
can't really say if it'll work, but it might be something to look at.

Thanks,

Seth Rowe [MVP]
 
M

Miro

Thanks,

Wanted to make sure I wasnt barking up the wrong tree with a 'global'
dataset.

I do like the 'class/module' idea.

Time to go play and experament.

Thanks again for the suggestions and info.

Miro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top