Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table naming - newbie question

Status
Not open for further replies.

tmryan

Programmer
Dec 22, 2000
73
0
0
US
I'm new to C# and ASP.Net - but catching on quickly. I inherited an application developed by a contractor - who was gone before the application went into Production (which was yesterday). In a nutshell - we have a problem happening intermittently (sp?). I was debugging for a specific customer number today and started seeing data for a totally un-related customer. I have a theory that says data is getting crossed when more than 1 user is using the application - which would explain why it wasn't noticed before - and possibly explains why it doesn't happen all the time. The tables are defined as follows:
public static DataTable writeDataTable;
public static DataTable readDataTable;

Wouldn't these tables be shared among all users? I would think that the tables should either be defined as private, or a user_id could be pre-pended to the table name - like
public static DataTable 'tmryan' + writeDataTable; (syntax?)

Any help would be greatly appreciated.

Thanks
Tim



Tim Ryan
PROGRESS Developer
 
As long as I understand, static variables are shared throughout the whole application. So you are right on it: you need to change the variable type.
 
Static members belong to the class, not individual object instances. This means that all objects instances of the class have access to the static member. Only use static data when it needs to be the same for all instances. If the data is specific to a particular instance, it should not be static. Accessors like private and protected do not have any relavance in this case.

If you can find it, a really good book that focuses on this stuff is the C# Class Desgin Handbook, by Wrox.

HTH



David
[pipe]
 
LV - Dragonwell,

Thanks for the info. I determined for sure today that the DataTables are being shared by all users. I was really surprised when I was stepping through the app in the debugger - and another user caused my debugger to take focus on my machine because they hit a breakpoint. What I really want is for each user to have their own instance of the table. I wish I had more than a couple days experience with this.

Thanks Again.

Tim

Tim Ryan
PROGRESS Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top