Shared datatable only shows data to one client....

I have a client/server app using a remoting object that is intended to share a single datatable with multiple clients.  The remoting object is as follows:

Public Class RemConnect
    Inherits MarshalByRefObject

    Public Shared dtAll As DataTable

    Shared Sub New()
        If dtAll Is Nothing Then dtAll = New DataTable
    End Sub
    Public Shared Property GetTable() As DataTable
            Return dtAll
        End Get
        Set(ByVal Value As DataTable)
            dtAll = Value.Copy
        End Set
    End Property
End Class

Then I have a host app that registers the tcp channel and service, executes a SQL query, and fills dtAll.  The clients open a channel on the same port (I listed WellKnown entries at each client and they can "see" the remote object correctly).  When any of my clients connect, dtAll appears to be empty.  If I add the code to run the query from a client, fill dtAll, then bind the client datagrid to dtAll, I see the data correctly on the client that ran the query, but the other client still sees dtAll as "nothing."  I'm not creating a new instance of the remoting object for each call from the client (that is, I'm using "RemConnect.GetTable" rather than Dim RC as new RemConnect, RC.GetTable), so I thought that it would just use an active instance of the object on the server.

Any help on the proper way to share the datatable so that it retains it's data across all instances of the class?  Or am I going at this all wrong for what I'm trying to accomplish?  Thanks in advance for any suggestions.
Who is Participating?
grayeConnect With a Mentor Commented:
How about the idea of a 2nd SQL server that handles just this one DataTable for your 80 clients?   This "head end" database would handle the load of your clients without any increase in traffic from the "real" backend mission critical database.  You could use SQL Server's own replication feature to syncronize the "head end" database with the backend database.

... just a thought
Whew... where to begin...

First of all, most folks don't use .Net Remoting for datatables.   That's because there is a teriffic alternative, namely... a database!    Think about it a second, that's what databases do "for a living".  They offer datatables to remote clients.   Consequently you won't find too many stituations where a program that you write can perform that function better.   This is particulary attractive, since SQL Server 2005 Express Edition is Free!

On to the specifics of your remoting class...   The key-word "Shared" in this context isn't really applicable.   The term "Shared" doesn't mean what you think it means... instead it means that the object is "static" (or to say it another way), can be called without a specific instance of the object.   In a remoting class, I rather doubt you'd have any shared members (because there's no way to get to the remote object without instantiating it).

Tell us more about what you're trying to do... perhaps we can provide some useful alternatives
feezymacAuthor Commented:
Thanks for the reply.

The reason I was using the datatable is that I'll have about 80 clients trying to connect simutaneously where every 10 or so are requesting an identical set of data and this "dataset" is refreshing every 2 seconds, and they're not sync'd, so it's basically a continuous barrage of queries from different network clients.  This app has to hit the same SQL server as a mission critical app for the company (they've been hesitant up to this point to even give me access), so I was trying to minimize the SQL server traffic as much as possible:  I was thinking that using the server app to query once (vs. 80 individual queries), parsing that dataset out to individual datatables, then distributing these to the appropriate clients (through the server app, which lives on another app server) would be less stressfull on the SQL server itself.  Honestly, the dataset is so small and the query so straight-forward (only 1 join) that I think the clients could connect directly without impacting the "main" app's performance, but again our IT staff is being anal about the whole thing.

Another idea I was tossing around was to have my server app run the query and use it to update a SQL server on another machine (any machine besides that dreaded mission critical SQL server) then just point the clients directly to that, so a dedicated SQL server just for this app.  Only problem there is I would have to go back to IT to request another box :)

Thanks again for the reply and any other ideas you have.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.