By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,106 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,106 IT Pros & Developers. It's quick & easy.

Best way to make a single "shared" dataset available to multiple Windows forms

P: n/a
I'm looking for the best way to make a dataset available from multiple
Windows forms. The dataset is created from
an XML file. I have a main form (frmMain) that loads the dataset and reads
the data but then I have other forms that give the ability to add, modify,
and delete rows. This of course changes the dataset and I need that
reflected in the main form. At first I was actually passing a reference of
the dataset to the "modify" form (frmModify). That worked but I just didn't
like it and sometimes my dataview of the dataset in frmMain wouldn't catch
the updates and I'd have to rebind everything. It just seemed kludgy. Now
I'm going down the path of a shared dataset in a module but I can't decide
if it's better to use a module or a class or if this is even the right way
to go. I found a MS article that seems to hint that shared members in a
class are a better way to go than a module
(http://support.microsoft.com/default...b;en-us;311319) but I don't
really see why. I guess am looking to have an "application" level dataset
that I can bind to in multiple forms. Then when I make any changes to it,
any form with datagrids, dataviews, etc. automatically reflect those
changes.

Surely others have run in to the issue of accessing a single dataset from
multiple Windows Forms. What's the "best practices" way to expose and
update a dataset from multiple Windows forms?

Thanks,

John Granade
John@Granade-nospam-.net

Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In a module I used this:
Public dsMain As New DataSet("MainDataSet")

It worked fine.

A VB module is a legacy holdover from VB6 and earlier.
There is no equivalent in C#.
Under the hood a module is converted to a shared class so I guess they are
suggesting you may as well learn how to write a shared class. It really does
not matter as far as execution goes.
--
Joe Fallon

"John Granade" <jo**@granade.net> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
I'm looking for the best way to make a dataset available from multiple
Windows forms. The dataset is created from
an XML file. I have a main form (frmMain) that loads the dataset and reads the data but then I have other forms that give the ability to add, modify,
and delete rows. This of course changes the dataset and I need that
reflected in the main form. At first I was actually passing a reference of the dataset to the "modify" form (frmModify). That worked but I just didn't like it and sometimes my dataview of the dataset in frmMain wouldn't catch
the updates and I'd have to rebind everything. It just seemed kludgy. Now I'm going down the path of a shared dataset in a module but I can't decide
if it's better to use a module or a class or if this is even the right way
to go. I found a MS article that seems to hint that shared members in a
class are a better way to go than a module
(http://support.microsoft.com/default...b;en-us;311319) but I don't really see why. I guess am looking to have an "application" level dataset
that I can bind to in multiple forms. Then when I make any changes to it,
any form with datagrids, dataviews, etc. automatically reflect those
changes.

Surely others have run in to the issue of accessing a single dataset from
multiple Windows Forms. What's the "best practices" way to expose and
update a dataset from multiple Windows forms?

Thanks,

John Granade
John@Granade-nospam-.net

Nov 20 '05 #2

P: n/a
Cor
Hi John,

I never did it this way.

But I think you can try it.

When you open the XML file in your designer you can make a dataset from
that.
It creates a XSD file and hidden, (you can see it when you set that in your
solution explorer as show all files) a dataset.vb class.

That is a complete class to read and write the dataset from everyplace.

I would give it a try in your situation.

Cor
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.