Error Trapping

Results 1 to 3 of 3

Thread: Error Trapping

  1. #1
    Join Date
    Dec 1969

    Default Error Trapping

    Hello,<BR><BR>The code below is in an asp file. I am attempting to detect the domain entered by a user in their browser and coming to my server, and based upon that domain, redirect them to a different site. The site they get redirected to is located in an access database. Hence, if the user were to type (example) into there browser, this code would look up in the database in domains.domain, and once it is found redirect the user with the contents of the<BR>associated redirect value in the domains.redirectpath field. I am having 2 problems:<BR><BR>1. Everything works fine until I change the original value in the<BR>domains.redirectpath field. The user still gets redirected to the original value, and not the updated value.<BR><BR>2. If the domain is not found in the access database, I want to print out a message such as domain not found. I do not know how to trap this situation, ie the record was not found. I&#039m sure it is something such as an if then statement checking for a null value, I just do not know the syntax to use.<BR><BR>Thanks in advance for any help you can give<BR><BR>&#060;%<BR>requesteddomain = request.servervariables("http_host")<BR>connectme= "DSN=cotbredirect.dsn"<BR>buildsql1 = "SELECT domains.domain, domains.redirectpath FROM domains<BR>WHERE domains.domain=&#039"<BR>buildsql2 = requesteddomain<BR>buildsql3 = "&#039"<BR>finalsql = buildsql1 & buildsql2 & buildsql3<BR>set rstemp=Server.CreateObject("adodb.Recordset")<BR>r finalsql, connectme<BR>website = rstemp.fields("redirectpath")<BR>if rstemp.fields("domain")= requesteddomain then<BR> response.redirect website<BR>End if<BR>rstemp.close<BR>set rstemp=nothing<BR><BR>%&#062;

  2. #2
    Jason Miller Guest

    Default RE: Error Trapping

    Sorry, I don&#039t understand #1<BR><BR>#2: &#060;insert after;<BR>if rstemp.eof then<BR>&#039 Code for thing not found<BR>else<BR>&#039 Code for thing found<BR>end if<BR>rstemp.close...

  3. #3 Guest

    Default RE: Error Trapping

    I don&#039t understand what you mean about changing the value of domains.redirectpath 1.<BR><BR>re: 2.<BR><BR>"if rstemp.BOF and rstemp.EOF then"<BR>will test for empty recordset.<BR><BR>You should do rstemp.close and set rstemp=nothing before you redirect. If the redirect succeed these two statements don&#039t get executed.

Posting Permissions

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