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

Re: Dataset being overwritten by multiple users? by Cowboy

Cowboy
Wed Mar 12 08:22:12 CDT 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" <coz1978@gmail.com> wrote in message
news:d32af846-20cb-46ed-a515-999fb0f6b74d@8g2000hse.googlegroups.com...
> 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



Re: Dataset being overwritten by multiple users? by Chris

Chris
Wed Mar 12 08:40:50 CDT 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=A0am, "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
> {
> =A0 =A0 get { ...}
> =A0 =A0 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
> =A0 =A0 Get
> =A0 =A0 =A0 =A0 ...
> =A0 =A0 End Get
> =A0 =A0 Set
> =A0 =A0 =A0 =A0 =A0...
> =A0 =A0 End Set
> End Property
>
> Now, you may not realize you are doing this, as it may be hidden in someon=
e
> else' library or a static/Shared class, etc.
>
> I have been working with .NET since the early 1.0 betas and have never see=
n
> 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.co=
m> wrote in message
>
> news:d32af846-20cb-46ed-a515-999fb0f6b74d@8g2000hse.googlegroups.com...
>
> > I've got an aspnet page (vb) that runs a stored procedure, pipes it in
> > a dataset, and binds to a gridview. =A0The parameters for the stored
> > procedure are some URL variables. =A0My problem is when multiple ( 2 or
> > more) people click on this link at the exact same time, the dataset
> > seems to be getting overwritten. =A0If 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. =A0I'm almost positive this has
> > something to do with multiple accessing the dataset at the same time.
> > Is this the case? =A0What's the workaround? =A0TIA


Re: Dataset being overwritten by multiple users? by Mark

Mark
Wed Mar 12 09:09:01 CDT 2008

"Chris" <coz1978@gmail.com> wrote in message
news:d3e20a20-0a61-4dee-89d6-610a8fbb6ccc@f63g2000hsf.googlegroups.com...

> 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


Re: Dataset being overwritten by multiple users? by Chris

Chris
Wed Mar 12 09:23:32 CDT 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=A0am, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:
> "Chris" <coz1...@gmail.com> wrote in message
>
> news:d3e20a20-0a61-4dee-89d6-610a8fbb6ccc@f63g2000hsf.googlegroups.com...
>
> > 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 acros=
s
> the entire application in ASP.NET...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net


Re: Dataset being overwritten by multiple users? by Cowboy

Cowboy
Wed Mar 12 09:03:11 CDT 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" <coz1978@gmail.com> wrote in message
news:d3e20a20-0a61-4dee-89d6-610a8fbb6ccc@f63g2000hsf.googlegroups.com...
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-999fb0f6b74d@8g2000hse.googlegroups.com...
>
> > 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



Re: Dataset being overwritten by multiple users? by Andrew

Andrew
Wed Mar 12 12:02:04 CDT 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



Re: Dataset being overwritten by multiple users? by Mark

Mark
Wed Mar 12 12:08:38 CDT 2008

"Chris" <coz1978@gmail.com> wrote in message
news:9de82f65-0a1f-48b8-8103-bd130f338a52@m44g2000hsc.googlegroups.com...

> > 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


Re: Dataset being overwritten by multiple users? by Mark

Mark
Wed Mar 12 12:14:38 CDT 2008

"Andrew Morton" <akm@in-press.co.uk.invalid> wrote in message
news:eUWCQLGhIHA.4320@TK2MSFTNGP06.phx.gbl...

> 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


Re: Dataset being overwritten by multiple users? by Cowboy

Cowboy
Wed Mar 12 12:57:02 CDT 2008

DataSets are XML, which is pretty much what serializable objects are
serialized to. :-)

For the record, a DataSet IS serializable.

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

*************************************************
| Think outside the box!
|
*************************************************
"Andrew Morton" <akm@in-press.co.uk.invalid> wrote in message
news:eUWCQLGhIHA.4320@TK2MSFTNGP06.phx.gbl...
> 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
>



Re: Dataset being overwritten by multiple users? by Cowboy

Cowboy
Wed Mar 12 12:56:21 CDT 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" <coz1978@gmail.com> wrote in message
news:9de82f65-0a1f-48b8-8103-bd130f338a52@m44g2000hsc.googlegroups.com...
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-610a8fbb6ccc@f63g2000hsf.googlegroups.com...
>
> > 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