Application Variable.

Results 1 to 2 of 2

Thread: Application Variable.

  1. #1
    Join Date
    Dec 1969

    Default Application Variable.

    Hi guys,<BR><BR>Further to my various questions about Populating select boxes with country values from a database. Someone mentioned the other day that If I have a common intensive call on my database I should shove the code within in an application variable. Could someone offer me guidance on exactly how to do this.<BR><BR>On my webpage a user returns and the form displays their previously saved information including RS("Country"). Now the intensive part is that the page selects all countrys from the database each time the users returns to the page and populates the select box. <BR><BR>The fact is this doesn&#039;t need to be done all that often as countrys don&#039;t outdate really. So my question is how would I modify the code below which is currently included on my asp page and make it an application variable and then call it? . <BR><BR>I&#039;m also a bit shady on the application variable. I.e. Who triggers it? Is it like an include file or what? I&#039;ve read the 4guys faq but i&#039;m still a bit confused.<BR><BR>My codes below and thanks in advance for any advice.<BR><BR>James<BR><BR>&#060;% <BR>Dim RSX<BR>Set RSX=Server.CreateObject("ADODB.recordset")<BR>RSX. Open "SELECT * FROM Country order by Country ID", "DSN=test;Server=testsql;Database=test;User Id=test; Password=test;"<BR>RSX.Movefirst<BR>Response.Write ("&#060;SELECT SIZE=""1"" Name=""Country"" Id=""Country "" tabindex=""94""&#062;" & _<BR> "&#060;OPTION VALUE= &#039;" & RS("Country") & "&#039;&#062;" & _<BR> RS("Country") & "&#060;/OPTION&#062;" )<BR>Do while NOT RSX.EOF<BR>Response.Write ("&#060;OPTION VALUE=" & RSX("Country") & "&#062;" & _<BR> "" & RSX("Country") & "&#060;/OPTION&#062;")<BR>RSX.MoveNext<BR>Loop<BR>RSX.Clos e<BR>Set RSX=nothing<BR>Response.Write ("&#060;/SELECT&#062;")<BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default Well, it's quite easy...

    ...instead of Response.Write-ing all that information to the screen, you put it into an application variable.<BR><BR>That&#039;s it. However, you only want to actually do this code if your application variable is blank. Something like<BR><BR>If Len(Application("CountryString")) = 0 then<BR> &#039; Populate Application("CountryString")!<BR>end if<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts