473,509 Members | 2,890 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

global variable

Hi,

I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not the
others. In need something like a class with static variables, but for each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

Thanks
May 2 '07 #1
9 1333

In a winforms/console application, a "singleton" design pattern can be used.

See
http://www.dofactory.com/Patterns/PatternSingleton.aspx

"martelpa" <ma******@discussions.microsoft.comwrote in message
news:E0**********************************@microsof t.com...
Hi,

I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not
the
others. In need something like a class with static variables, but for
each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

Thanks

May 2 '07 #2
martelpa <ma******@discussions.microsoft.comwrote:
I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not the
others. In need something like a class with static variables, but for each
user independently. In a Web app it would probably be the in Session, but
it's a console app.
It's not clear to me whether you're in a situation where there will be
multiple users within the same process for transient data, or whether
you're talking about storing data between sessions (i.e. between
shutting down the process once and starting it up again).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 2 '07 #3
Hi,

Thanks for your reply!

Here's an example... there will be multiple users using the same app, but
each of them have a particular ConnectionString (dynamically built at runtime
with their login and pwd). The ConnectionString need to be accessble from
every Data Acess Class.

So I can't put the ConnectionString in the App.Config, because it's
different for each user. And I can't use a static variable in a "Global
Class" because they will be multiple user...

Thank

"Jon Skeet [C# MVP]" wrote:
martelpa <ma******@discussions.microsoft.comwrote:
I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not the
others. In need something like a class with static variables, but for each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

It's not clear to me whether you're in a situation where there will be
multiple users within the same process for transient data, or whether
you're talking about storing data between sessions (i.e. between
shutting down the process once and starting it up again).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 2 '07 #4
Hi,

I'm not sure that will work in my case. I need something like...every user
have his Singleton.

I want to build the connectionString at runtime for each user and then I
have to store it somewhere...and it need to accessble from every Data Access
Layer Class.

Thanks

"sloan" wrote:
>
In a winforms/console application, a "singleton" design pattern can be used.

See
http://www.dofactory.com/Patterns/PatternSingleton.aspx

"martelpa" <ma******@discussions.microsoft.comwrote in message
news:E0**********************************@microsof t.com...
Hi,

I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not
the
others. In need something like a class with static variables, but for
each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

Thanks


May 2 '07 #5
martelpa <ma******@discussions.microsoft.comwrote:
Thanks for your reply!

Here's an example... there will be multiple users using the same app, but
each of them have a particular ConnectionString (dynamically built at runtime
with their login and pwd). The ConnectionString need to be accessble from
every Data Acess Class.
You still haven't made it clear whether the multiple users will be
using the same active process at the same time (and if so, how), or
whether it's different users running the same program, but only one
user interacting with any given process.
So I can't put the ConnectionString in the App.Config, because it's
different for each user. And I can't use a static variable in a "Global
Class" because they will be multiple user...
Hopefully once you've made it clear exactly what's going on, a solution
will present itself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 2 '07 #6

Try
"user.config"
http://msdn2.microsoft.com/en-us/lib...xh(VS.80).aspx
or
http://www.google.com/search?q=app.c...&start=10&sa=N

You could be the info in the user.config file AND use the Singleton method.

The Singleton (when it doesn't exist) can read the user.config file. And
then you don't have to keep re-reading the config file.

"martelpa" <ma******@discussions.microsoft.comwrote in message
news:E0**********************************@microsof t.com...
Hi,

I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not
the
others. In need something like a class with static variables, but for
each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

Thanks

May 3 '07 #7
Hi,

That's what is going on..."different users running the same program, but
only one user interacting with any given process"

Thanks

"Jon Skeet [C# MVP]" wrote:
martelpa <ma******@discussions.microsoft.comwrote:
Thanks for your reply!

Here's an example... there will be multiple users using the same app, but
each of them have a particular ConnectionString (dynamically built at runtime
with their login and pwd). The ConnectionString need to be accessble from
every Data Acess Class.

You still haven't made it clear whether the multiple users will be
using the same active process at the same time (and if so, how), or
whether it's different users running the same program, but only one
user interacting with any given process.
So I can't put the ConnectionString in the App.Config, because it's
different for each user. And I can't use a static variable in a "Global
Class" because they will be multiple user...

Hopefully once you've made it clear exactly what's going on, a solution
will present itself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 4 '07 #8
martelpa <ma******@discussions.microsoft.comwrote:
That's what is going on..."different users running the same program, but
only one user interacting with any given process"
In which case, you can certainly use a static variable, because you'll
have one static variable for each process. The value of a static
variable isn't magically persisted between processes.

So, you just need a way of storing per-user information so you can load
it on startup. I believe the configuration classes in .NET 2 are gears
towards this. An alternative (if you're using .NET 1.1, for instance)
is to use the registry, or store a separate file in a folder specific
to each user (e.g. their docs and settings directory). See
Environment.GetFolderPath for a way of retrieving an appropriate
directory.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 4 '07 #9
Probably Settings file can solve your issue. Settings can be segregated by
user.

If you need more security/control, you can derive from generated class.

in VS2005 just add Settings file to project.

HTH
Alex

"martelpa" <ma******@discussions.microsoft.comwrote in message
news:E0**********************************@microsof t.com...
Hi,

I would like to store data for a specific user in multi-user environnment.
I need the data to be accessible to all class for a specific user but not
the
others. In need something like a class with static variables, but for
each
user independently. In a Web app it would probably be the in Session, but
it's a console app.

Thanks

May 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
102743
by: David Hitillambeau | last post by:
Hi guys, As I am new to Python, i was wondering how to declare and use global variables. Suppose i have the following structure in the same module (same file): def foo: <instructions>...
4
24160
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); ...
4
7096
by: Dan Elliott | last post by:
Hello, Converting from a working C program to C++, I run into the following error: I have a header: (header.h) namespace shared{ ... struct X{ ...
2
8803
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
8
2509
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
17
5591
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm...
10
2631
by: Charles O'Flynn | last post by:
As a complete newcomer (2-3 days) to PHP, although not to programming in general, I have 'dived in' to start a small project to read and parse an XML data stream. I have already worked out most of...
9
2990
by: Ed Jensen | last post by:
I'm having a vexing problem with global variables in Python. Please consider the following Python code: #! /usr/bin/env python def tiny(): bar = for tmp in foo: bar.append(tmp) foo = bar
1
29312
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
112
5350
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
0
7136
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7344
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7412
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3216
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
441
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.