Re: Keeping global stuff in a windows program. by Mufasa
Mufasa
Thu Aug 28 14:43:47 CDT 2008
Thanks for the info but I already know about the configuration files.
I mean I want global things like definitions/global variables....
For instance - somebody logs in - I want to keep the user name they logged
in as somewhere so all of my modules/windows/whatever have access to it.
Writing it into the configuration files doesn't seem right. And I'm not
using Windows Authentication.
As far as the connections to the database, I'm not worried about running out
of connections. I'm more worried that if I close the DB and reopen it every
time I need to do that, it will be slow (our connection is to a DB that is
stored off site and the WAN to that DB is slow). So I'd like to leave the
connection open with logic to check to make sure the connection is open and
active. I understand that there will be issues with that but it will provide
a better user experience.
So for instance - Let's suppose a user logs in. I check to see what
privileges they have. Let's supposed I have a security module that does all
the checking and sets up things so I can later know what options they have.
But now what? All my other forms/modules don't have access to this instance
of the security module unless I pass it around which seems cumbersome. Do I
make the module static? Would that mean that everybody can access the module
and any changes one form makes everybody can see? So Form A logs the person
in. The Security Module loads all of their information and then
automatically Form B sees those changes?
TIA - Jeff.
"Mr. Arnold" <MR. Arnold@Arnold.com> wrote in message
news:Obz$hlICJHA.1628@TK2MSFTNGP03.phx.gbl...
>
> "Mufasa" <jb@nowhere.com> wrote in message
> news:uK94RpHCJHA.2476@TK2MSFTNGP06.phx.gbl...
>>I have done lots of stuff with ASP.Net but am now starting to do stuff
>>with VB.Net. My question is how do you keep stuff around that is global? I
>>mean things like the user name and what not?
>>
>> In ASP.Net you'd put it in to Session variables but there doesn't seem to
>> be anything like that in Windows.
>
> ASP.NET with a WEB server is a stateless session between Web client and
> Web server, meaning all connections between the client and the Web server
> are broken and must be established between round trips between the client
> and the server each time. So, one has to keep things in a session variable
> to keep state with session information between round trips between Web
> client and Web server, and it's only for that particular session and is
> not global.
>
>>
>> I want to keep things like connections to databases, user info, ... all
>> in one place and have them persist (especially the DB connections because
>> our connection to the DB is slow so it is slow on the open and close.)
>
> That maybe true for a Web application where multiple connections are being
> opened by multiple users that are in session with the Web server, with
> the Web server being the single machine that is initiating connections to
> the DB for all users. And in addition, the DB admin for the DB server
> doesn't know who to use connection pooling or the Web application is not
> using a generic user-id and psw for all database connections taking
> advantage of connection pooling.
>
> Windows desktop solutions are stateful solutions running on a single
> machine/workstation, meaning that as long as the application is running on
> the single machine/workstation, it has state with all elements within its
> scope of it being a running program and nothing is out of session, and
> its never out of session. Connection pooling with a generic user id and
> psw could be used their to, but most would use Windows Authentication for
> desktop solutions.
>
> As long as the connection is being made for each single
> machine/workstation, then there is going to be no speed issues on
> open/close connections. You could just leave the connection open until the
> program is ended, but you run the risk of using up all available
> connections to the database server is the user just left the program
> unattended and many users were doing it.
>
> You want things to persist, like user info, database connection info etc,
> etc, then one uses the app.config for Windows Desktop solutions, and you
> keep reading the app.config, like one would use web.config for Web
> solutions.
>
>
>
>
>