Variable Question, explained better!

Results 1 to 2 of 2

Thread: Variable Question, explained better!

  1. #1
    Join Date
    Dec 1969

    Default Variable Question, explained better!

    I am going to try explain this variable issue again that I am dealing with. I apologize if my previous posts were not as clear as they need be.<BR><BR>I am working with a form on a page (form.asp) to perform a search on a database. I have three different criteria for searching this database: Owner, Address and Type.<BR><BR>Each search type has a different form. After the user types in their search and clicks the search button, the are take to a results.asp page. On this page, I take the Request.Form information, including the type of search performed and the search criteria, and I set them to local varibles. I then base my SQL statement on those local variables to query the database and produce a list.<BR><BR>For example, if I perform an Owner search, one of the first things that gets done on results.asp is:<BR>strSearchType=Request.Form("Type")<BR><BR>T his results in strSearchType="Owner". Then I set the search criteria to local variables, also.<BR><BR>strLastName=Request.Form("Last")<BR>s trFirstName=Request.Form("First") , etc.<BR><BR>This all works fine if I just show an unlimited amount of results on a page. However, when I try to limit the results.asp to 10 results (I used this article I found on @ ), with a Next Page and Previous Page, I run into a problem.<BR><BR>The problem is that all my variables lose their values. Therefore, when I click on Next Page, which is results.asp?currentpage=2, all the variables that I have used to create my SQL statement are now empty.<BR><BR>strSearchType=Request.Form("Type")<B R>This sets strSearchType = ""<BR><BR>strLastName=Request.Form("Last")<BR>strF irstName=Request.Form("First") , etc.<BR>This sets strLastName and strFirstName = ""<BR><BR>Is there anyway that I can set a variable that is more permenant?<BR><BR>Thanks a lot, everyone!<BR><BR>PS- if anyone wants the code for the two pages, give me your e-mail address and I will forward that to you.

  2. #2
    RustyKnight Guest

    Default RE: Variable Question, explained better!

    Chris<BR><BR>You have two choices for passing this information on to the next page in sequence:<BR><BR>High Usage Environment:<BR>Response.Redirect "results.asp?currentpage=2&Type=" & strSearchType<BR>you will have to follow the above example and append all your variables to the redirect URL. Then on the other end use the Request.QueryString("Type") to retrieve your values. This requires more upfront coding but will scale up very well. Note also to use the Server.URLEncode Function to format your redirect strings prior to use, to ensure error free operation. <BR><BR>Low Usage Environment:<BR><BR>Session("strSearchType") = Request.Form("Type")<BR><BR>This creates a instance of the session object for every user on the site and will require users machines to accept cookies. But you then have a sort of global variable by user, that can be accessed on any page. This method works very well except that it eats memory quickly and under high usage conditions will quickly swamp a server.<BR><BR><BR>Good Luck<BR><BR>

Posting Permissions

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