PC Review


Reply
Thread Tools Rate Thread

Dataset being overwritten by multiple users?

 
 
Chris
Guest
Posts: n/a
 
      12th Mar 2008
I've got an aspnet page (vb) that runs a stored procedure, pipes it in
a dataset, and binds to a gridview. The parameters for the stored
procedure are some URL variables. My problem is when multiple ( 2 or
more) people click on this link at the exact same time, the dataset
seems to be getting overwritten. If person A clicks on their link,
and person B clicks on theirs at the same time, person A is getting
Person B's data, and vice versa. I'm almost positive this has
something to do with multiple accessing the dataset at the same time.
Is this the case? What's the workaround? TIA
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12th Mar 2008
Most likely you are using a DataSet that looks something like this:

private static DataSet _dataSet;

//Routine to fill DataSet here
//Something to return the DataSet

public static DataSet Data
{
get { ...}
set { ... }
}

If you program in VB, the word here is Shared.

Private Shared data As DataSet

'Routine to fill DataSet here
'Something to return the DataSet

Public Shared Property Data As DataSet
Get
...
End Get
Set
...
End Set
End Property

Now, you may not realize you are doing this, as it may be hidden in someone
else' library or a static/Shared class, etc.

I have been working with .NET since the early 1.0 betas and have never seen
data cross like you are describing without something static/Shared. Most
often people here that static/Shared members are more efficient, which is
true in helper methods, but static/Shared means (quoting from Highlander)
"There can be only one". :-)

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

*************************************************
| Think outside the box!
|
*************************************************
"Chris" <(E-Mail Removed)> wrote in message
news:d32af846-20cb-46ed-a515-(E-Mail Removed)...
> I've got an aspnet page (vb) that runs a stored procedure, pipes it in
> a dataset, and binds to a gridview. The parameters for the stored
> procedure are some URL variables. My problem is when multiple ( 2 or
> more) people click on this link at the exact same time, the dataset
> seems to be getting overwritten. If person A clicks on their link,
> and person B clicks on theirs at the same time, person A is getting
> Person B's data, and vice versa. I'm almost positive this has
> something to do with multiple accessing the dataset at the same time.
> Is this the case? What's the workaround? TIA



 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      12th Mar 2008
Yep, you're correct.

I'm doing a 'Public Shared blahblah as new DataSet', inside the class.

Partial Class test
Inherits System.Web.UI.Page
Public Shared ds As New DataSet

On Mar 12, 9:22*am, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamM> wrote:
> Most likely you are using a DataSet that looks something like this:
>
> private static DataSet _dataSet;
>
> //Routine to fill DataSet here
> //Something to return the DataSet
>
> public static DataSet Data
> {
> * * get { ...}
> * * set { ... }
>
> }
>
> If you program in VB, the word here is Shared.
>
> Private Shared data As DataSet
>
> 'Routine to fill DataSet here
> 'Something to return the DataSet
>
> Public Shared Property Data As DataSet
> * * Get
> * * * * ...
> * * End Get
> * * Set
> * * * * *...
> * * End Set
> End Property
>
> Now, you may not realize you are doing this, as it may be hidden in someone
> else' library or a static/Shared class, etc.
>
> I have been working with .NET since the early 1.0 betas and have never seen
> data cross like you are describing without something static/Shared. Most
> often people here that static/Shared members are more efficient, which is
> true in helper methods, but static/Shared means (quoting from Highlander)
> "There can be only one". :-)
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> *************************************************
> | Think outside the box!
> |
> *************************************************"Chris" <coz1...@gmail.com> wrote in message
>
> news:d32af846-20cb-46ed-a515-(E-Mail Removed)...
>
> > I've got an aspnet page (vb) that runs a stored procedure, pipes it in
> > a dataset, and binds to a gridview. *The parameters for the stored
> > procedure are some URL variables. *My problem is when multiple ( 2 or
> > more) people click on this link at the exact same time, the dataset
> > seems to be getting overwritten. *If person A clicks on their link,
> > and person B clicks on theirs at the same time, person A is getting
> > Person B's data, and vice versa. *I'm almost positive this has
> > something to do with multiple accessing the dataset at the same time.
> > Is this the case? *What's the workaround? *TIA


 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12th Mar 2008
Years ago, I consulted on a project where the user was actually changing as
someone was doing work. The app was not allowed into the wild due to this
FUBAR. I found this:

public class ApplicationSettings
{
private static ApplicationSettings _appSettings;
private static User _websiteUser;

private ApplicationSettings() {}

public ApplicationSettings GetSingleton()
{
}

public ApplicationSettings GetSingleton(string userName)
{
}
}

The second GetSingleton was set up to load a User when the person originally
signed in.

The developer thought he was okay, since he was doing this:

Session["appSettings"] = ApplicationSettings.GetSingleton(userName);

Does not matter if you load this into Session or not, as it is a Singleton.
That is one instance per entire application, not per session. He was
constantly flipping from user's object to user's object. Furthermore,
sometimes he was pulling like this:

appSettings = Session["appSettings"];

and sometimes like this:

appSettings = ApplicationSettings.GetSingleton();

I have also seen this:

private static SqlConnection;

public static SqlConnection GetSqlConnection()
{
}

This works fine on a low usage site, but becomes a bottleneck rather quickly
when scaling.

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

*************************************************
| Think outside the box!
|
*************************************************
"Chris" <(E-Mail Removed)> wrote in message
news:d3e20a20-0a61-4dee-89d6-(E-Mail Removed)...
Yep, you're correct.

I'm doing a 'Public Shared blahblah as new DataSet', inside the class.

Partial Class test
Inherits System.Web.UI.Page
Public Shared ds As New DataSet

On Mar 12, 9:22 am, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamM> wrote:
> Most likely you are using a DataSet that looks something like this:
>
> private static DataSet _dataSet;
>
> //Routine to fill DataSet here
> //Something to return the DataSet
>
> public static DataSet Data
> {
> get { ...}
> set { ... }
>
> }
>
> If you program in VB, the word here is Shared.
>
> Private Shared data As DataSet
>
> 'Routine to fill DataSet here
> 'Something to return the DataSet
>
> Public Shared Property Data As DataSet
> Get
> ...
> End Get
> Set
> ...
> End Set
> End Property
>
> Now, you may not realize you are doing this, as it may be hidden in
> someone
> else' library or a static/Shared class, etc.
>
> I have been working with .NET since the early 1.0 betas and have never
> seen
> data cross like you are describing without something static/Shared. Most
> often people here that static/Shared members are more efficient, which is
> true in helper methods, but static/Shared means (quoting from Highlander)
> "There can be only one". :-)
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> *************************************************
> | Think outside the box!
> |
> *************************************************"Chris"
> <coz1...@gmail.com> wrote in message
>
> news:d32af846-20cb-46ed-a515-(E-Mail Removed)...
>
> > I've got an aspnet page (vb) that runs a stored procedure, pipes it in
> > a dataset, and binds to a gridview. The parameters for the stored
> > procedure are some URL variables. My problem is when multiple ( 2 or
> > more) people click on this link at the exact same time, the dataset
> > seems to be getting overwritten. If person A clicks on their link,
> > and person B clicks on theirs at the same time, person A is getting
> > Person B's data, and vice versa. I'm almost positive this has
> > something to do with multiple accessing the dataset at the same time.
> > Is this the case? What's the workaround? TIA



 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      12th Mar 2008
"Chris" <(E-Mail Removed)> wrote in message
news:d3e20a20-0a61-4dee-89d6-(E-Mail Removed)...

> Yep, you're correct.
>
> I'm doing a 'Public Shared blahblah as new DataSet', inside the class.


And that's the problem... Shared variables (static in C#) are shared across
the entire application in ASP.NET...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Chris
Guest
Posts: n/a
 
      12th Mar 2008
Makes sense now. Good ol' hindsight. So what other options do I have
if I want to put this query in a dataset, but retain the information
in the dataset after postbacks?

On Mar 12, 10:09*am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "Chris" <coz1...@gmail.com> wrote in message
>
> news:d3e20a20-0a61-4dee-89d6-(E-Mail Removed)...
>
> > Yep, you're correct.

>
> > I'm doing a 'Public Shared blahblah as new DataSet', inside the class.

>
> And that's the problem... Shared variables (static in C#) are shared across
> the entire application in ASP.NET...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      12th Mar 2008
Chris wrote:
> Makes sense now. Good ol' hindsight. So what other options do I have
> if I want to put this query in a dataset, but retain the information
> in the dataset after postbacks?


You can save data in the Session state (but I have a nagging suspicion that
a dataset is not serializable, so you'd have to figure out a way to get the
data into something that is, like an ArrayList).

Andrew


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      12th Mar 2008
"Chris" <(E-Mail Removed)> wrote in message
news:9de82f65-0a1f-48b8-8103-(E-Mail Removed)...

> > Yep, you're correct.

>
> > I'm doing a 'Public Shared blahblah as new DataSet', inside the class.

>
> And that's the problem... Shared variables (static in C#) are shared
> across
> the entire application in ASP.NET...
>
> Makes sense now. Good ol' hindsight. So what other options do I have
> if I want to put this query in a dataset, but retain the information
> in the dataset after postbacks?


Remove the word 'Shared'


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      12th Mar 2008
"Andrew Morton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I have a nagging suspicion that a dataset is not serializable


Yes it is - I do this all the time for smallish sets of data which (almost)
never changes e.g. countries, currencies etc...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12th Mar 2008
Cache. Viewstate. Session.

I am not going to recommend one over the others without knowing more about
your application. You might also find that it is more efficient to simply
query from the persisted store each time.

If the built in .NET items are not working for you, there are other cache
solutions out there, like nCache from www.alachisoft.com. Not recommending
that particular product, but it is one possiblity.

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

*************************************************
| Think outside the box!
|
*************************************************
"Chris" <(E-Mail Removed)> wrote in message
news:9de82f65-0a1f-48b8-8103-(E-Mail Removed)...
Makes sense now. Good ol' hindsight. So what other options do I have
if I want to put this query in a dataset, but retain the information
in the dataset after postbacks?

On Mar 12, 10:09 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "Chris" <coz1...@gmail.com> wrote in message
>
> news:d3e20a20-0a61-4dee-89d6-(E-Mail Removed)...
>
> > Yep, you're correct.

>
> > I'm doing a 'Public Shared blahblah as new DataSet', inside the class.

>
> And that's the problem... Shared variables (static in C#) are shared
> across
> the entire application in ASP.NET...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net



 
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
sharing excel sheet with multiple users, but other users cant see lana.b Microsoft Excel Misc 3 25th Jan 2009 11:15 AM
DataSet Designer/adding multiple tables to a dataset/ how? =?Utf-8?B?Q3VydGlz?= Microsoft ADO .NET 1 21st Aug 2006 02:09 PM
fill dataset/grid with multiple queries from multiple servers Dave Edwards Microsoft VB .NET 4 20th Jul 2004 10:49 AM
Dataset filtering for Authenticated users Nugs Microsoft ASP .NET 1 25th Apr 2004 12:55 AM
.NET Multi Users Using DataSet Question! Lester Moreno Microsoft C# .NET 1 1st Aug 2003 04:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 AM.