473,396 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
2 6874
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Berthold Hoellmann | last post by:
Hello, When I use ./configure --with-thread --with-fpectl --with-signal-module \ --with-pymalloc --enable-shared --with-cxx=g++ make test on 2.3.3 I get
8
by: The CQMMAN | last post by:
Hello, When I try to connect to my Oracle instance on the W2K server that it is installed on, using SQLPLUS (ie, SQLPLUS user/password@instance), I get: ORA-01034: ORACLE not available...
2
by: Jenna Schmidt | last post by:
I know that one of the benefits of using "Shared" methods is you do not explicitly have to Dim as New object to access the method. Are there some other implications with memory and concurrency...
6
by: Ross | last post by:
MyWebProject.MyWebForm1.someset.somedata is a datatable within a dataset. Displays quite nicely, too. Now I want to use the same data in MyWebProject.MyWebForm2. Being a old, er, experienced Java...
7
by: kratz | last post by:
I have seen some posts on this subject but I still cannot make my app work right. I have a MDI application with a parent form and two child forms. The parent form is called Mainform The child...
7
by: Carsten H. Pedersen | last post by:
Hello I want to create a kind of shared object. I have created a class, Counter, which you can then import. Through the Counter class, i would like to have access to a shared object. Lets say...
4
by: Greg | last post by:
I'm looking for suggestions of where you feel the best Windows shared hosting is. Basic requirements: * ASP.NET * MS SQL Server * User control over setting applications, etc. * Multiple...
3
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte()...
1
by: sap0321 | last post by:
This should be kindergarten stuff but for some reason I am having trouble with it. I do 99.9% web programming and this is the first windows app i've done in years - probably the first ever in C# ......
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.