PC Review


Reply
Thread Tools Rate Thread

Best way to share DataSets?

 
 
navilon
Guest
Posts: n/a
 
      25th Nov 2007
In my project I have several different forms that need access to the
same datasets, table adapters and binding sources. I have created a
static class called 'Globals.cs' which contains one of each. The
problem is that none of my forms recognize them. It's as if it will
only see instances within its own class.

Maybe I'm going about this the wrong way, it just seems redundant to
have every form have an instance of a dataset, table adapter and
binding source. Any information would be much appreciated.

Thanks,
Simon
 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      25th Nov 2007
Simon,

First, create a base form which will expose the data
sets/tables/adapters which you added to the form through the designer. Make
sure the accessibility of those members is public or protected.

Then, in the constructor of that form, assign the local field references
to the ones that you expose in your static class. Make sure this is done
after InitializeComponent call.

Of course, there is going to be some overhead because the call to
InitializeComponent is going to create the instances of these fields. If
you are trying to eliminate that overhead (which shouldn't be much to begin
with), then this won't work, but the assumption is that you have some
configuration that you want to share.

Then, derive your forms from that base form.

--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"navilon" <(E-Mail Removed)> wrote in message
news:3f256b8f-a522-42c2-bc4f-(E-Mail Removed)...
> In my project I have several different forms that need access to the
> same datasets, table adapters and binding sources. I have created a
> static class called 'Globals.cs' which contains one of each. The
> problem is that none of my forms recognize them. It's as if it will
> only see instances within its own class.
>
> Maybe I'm going about this the wrong way, it just seems redundant to
> have every form have an instance of a dataset, table adapter and
> binding source. Any information would be much appreciated.
>
> Thanks,
> Simon


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? Francisco Garcia Microsoft ASP .NET 2 13th Apr 2006 11:41 AM
How do Datasets manage to get deserialized as DataSets instead of a wsdl.exe-created proxy class? news.microsoft.com Microsoft ASP .NET 0 12th Apr 2006 10:07 AM
Discussion: Typet DataSets vs Untyped DataSets Przemo Microsoft VB .NET 11 3rd Sep 2004 07:58 AM
Typed DataSets returned as regular datasets =?Utf-8?B?Sm9uIEtpbmc=?= Microsoft ADO .NET 2 29th Aug 2004 01:41 AM
Converting Untyped Datasets into Strongly Typed Datasets with Foreign Key Constraints. Alex Berryhill Microsoft ADO .NET 2 19th Mar 2004 02:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 AM.