Mufasa said:
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.