Re: where to put this code?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Lucas Tam (REMOVEnntp_at_rogers.com)
Date: 12/11/04


Date: Sat, 11 Dec 2004 08:10:49 GMT


"V. Jenks" <anonymous@discussions.microsoft.com> wrote in
news:114001c4df45$f750ed70$a401280a@phx.gbl:

> What I need is a way to safely store the current string and
> the 2 integers in a way that will guarantee I do not lose
> the values, it is important that each time I generate the
> string, it is unique, as it is used as a primary key in my
> database tables.

Not a very safe way of generating PKs... Isn't there anything else you
can use a PK? Or this newly generate PK should be checked as soon as
possible to ensure it's uniquness.
 
> If I were to load the values from say, an XML file when the
> program loads in Application_Start in the Global.asax
> code-behind, could I safely keep them in memory and are
> they guaranteed to remain in state while the application is
> running? I was thinking I would re-write the values back
> into the XML file in the Application_End event handler.

No, if the application crashes, bye bye values!

> BUT...when exactly is Application_Start fired and when
> exactly is Application_End fired? What constitutes a web
> application starting and ending? Does it end when there
> are no more active sessions in the app?

Applicatin Start is fired when the application is first loaded.

Application End is fired when the application is shut down - I believe
typically 20+ minutes of inactivity. There maybe other situations where
application end is fired.

But generally speaking, you don't want to use Application_End for
process that MUST occur... because application_end has been shown to be
unreliable from time to time.

> Could I safely pull this off w/o any concurrency problems
> when writing/reading to the XML files to get my values?
>
> I would store these values in a database table but I don't
> want to make a new connection and round-trip to the
> database every time I need a value to insert as a primary
> key, this would murder my app's performance.

Perhaps you should look at generating the key in the database?

Or add some error handling logic in your PK generation routines... such
as checking the PK to make sure it's a valid PK before returning back to
the user. It's probably not a good idea just to rely on an XML file or
in memory store... as they could get out of sync with the server or data
could have been lost on a crash.

-- 
Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Relevant Pages

  • Re: Intranet Design Question
    ... "You don't actually have to use a database, you could store the info in an ... > link to the logon site. ... > an XML file since it would not have many columns. ...
    (microsoft.public.inetserver.iis.security)
  • Re: Store XML in a Database
    ... > Access database, by the help of SQL. ... Do you need to just store the XML string or convert it into its ... the XML file maps to the database. ...
    (comp.lang.java)
  • Re: Huge Web form
    ... i'd use a database and store the xml file there ... store the guid in a hidden file. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Where to store connection info ?
    ... store it in a database. ... Therefore you have the choise from an XML file, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: DBIx::XML::DataLoader
    ... Is there a package or utility that can read an XML file of the sort I ... The dbinfo specifies the login ... credentials to the database, and the database. ... And, I have no idea what XPATH is, let alone what to do with it. ...
    (comp.lang.perl.misc)