473,809 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Redirecting a page

147 New Member
Hi

I am currently using a page redirect which is the wrong thing to do (I think).

I am trying to be clever and work on a search algorythm (if that's the correct term).

We have a series of part numbers that start with 4 - 6 numbers, then the rest are customer specifiable. A good (made up) example could be the part number
Honda-4dr-Dsl-Auto
This is probably quite obvious - A honda, 4 door, Diesel and Automatic.
An example of my part numbers is
SHTSHC-2 - 20 - D - 100 - 04 - G - XX - X - LF

The first part (SHTSHC-2) is in the database and cannot alter. A user can search for just SHTSHC-2 or include more of the information (eg, SHTSHC-2-20-D-100), and my code has to display the correct part.

The only way around this I could see was to count how many characters were in the search query and then try it's initial search. If there are no matches, remove the last letter of the search and try again. And again.

To do this, I am using redirects, which must be the wrong thing to do. I hope I have explained this well enough. I am connecting to an Access db. Is there a better way to refresh the database with out the use of the redirect?

Here is my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%
  3. 'Create and define variables 
  4. Dim rsPCB__dataSearchResult, int_QueryLength
  5. rsPCB__dataSearchResult = "%"
  6. int_QueryLength=0
  7.  
  8. 'Request the users query and convert it into variable
  9. If (request.QueryString("data")<>"") Then 
  10. rsPCB__dataSearchResult = request.QueryString("data")
  11.  
  12.         'Removes white space and XX and XXX from search query
  13.      rsPCB__dataSearchResult = (Replace(rsPCB__dataSearchResult, " ",""))
  14.      rsPCB__dataSearchResult = (Replace(rsPCB__dataSearchResult, "XXX",""))
  15.      rsPCB__dataSearchResult = (Replace(rsPCB__dataSearchResult, "XX",""))     
  16.  
  17. 'work out how many characters the variable is and assign to new variable
  18.     int_QueryLength = Len(rsPCB__dataSearchResult)
  19.  
  20.  
  21. 'connect to database and send SQL
  22. Dim rsPCB
  23. Dim rsPCB_numRows
  24.  
  25. Set rsPCB = Server.CreateObject("ADODB.Recordset")
  26. rsPCB.ActiveConnection = MM_DataBase_STRING
  27. rsPCB.Source = "SELECT * FROM pcb WHERE ProductNumber like '" + Replace(rsPCB__dataSearchResult, "'", "''") + "' ORDER BY ProductNumber ASC"
  28. rsPCB.CursorType = 0
  29. rsPCB.CursorLocation = 2
  30. rsPCB.LockType = 1
  31. rsPCB.Open()
  32. rsPCB_numRows = 0
  33.  
  34. 'if the query doesn't match, remove the last digit of their query until it matches, or until there are no characters in the query left to search
  35.  
  36.         Do while (rsPCB.EOF and rsPCB.BOF or int_QueryLength = 0)
  37.         int_QueryLength = int_QueryLength - 1
  38.         rsPCB__dataSearchResult = Left((rsPCB__dataSearchResult),int_QueryLength)
  39.  
  40. ' I don't know how to resend the query with out refreshing the page        Response.Redirect("http://www.xxxxxxx.com/searchresults02.asp?data="& rsPCB__dataSearchResult)
  41.         Loop 
  42. End If
  43.  
  44. %>
  45.  
Thank you again for your help.
May 23 '08 #1
1 1509
DrBunchman
979 Recognized Expert Contributor
Hi Dave,

You could retrieve a recordset based on the fixed part of your search string. This recordset would contain all records which matched the first, fixed part.Then iterate through the recordset comparing each ProductNumber value with your search string. You can do this as many times as required, reducing the length of the search string each time until you find a record that matches. Doing it this way means you only need to open query the database once which will reduce your overheads.

This could probably be optimised further but off the top of my head I think this would work fine.

Does this make sense?

Dr B
May 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2336
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the main page from the code behind the contents page. I want to do this to allow the use of asp "linkbuttons" instead of hyperlinks so I can do a little processing before redirecting. The main reason for this to prevent hyperlinks of pages that have...
0
2145
by: Sune Hansen | last post by:
Hi guys, I really hope someone can help me with my problem. Here is the scenario: I have a development environment on my locale machine. Once in a while when everything has been tested I publish it to the live server. This has been working well for some time. Now, all of a sudden, when I publish my site it no longer works on the live server. It seemes as if it keeps redirecting to the same page over and over
1
1860
by: Bilbo | last post by:
Hello, How do I programatically redirect a page in "another frame" using C# in ASP.NET? Server.Transfer redirects the current page...not a different frame. Thanks.
3
2469
by: tony | last post by:
I've been searching through the threads to find a solution for 401.3 error triggered by windows authentication not being able to redirect to a custom error page to no avail. It seems that ASP.NET does not redirect 401 errors yet changing the Custom Errors redirect in IIS does not help either. Has anyone found a solution to this problem? Seems like it should be a commonly encountered problem. Any help will be greatly appreciated.
4
1498
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you are redirecting to somewhere that doesn't exist. Worse, if you do type it correctly, but then later the page name changes or the page moves, you still won't find out until run time. I have a framework that solves this problem and guarantees,...
4
2188
by: deepukutty | last post by:
HI all, I am using IE(Internet Explorer) as my default browser for asp.net application development. Today i faced a strange problem. When ever an exception occured in the page ....application is not redirecting to the default error page which will normally come. instead page is redirecting to "http://help.internet-optimizer.com/?js=1&e=ERR500&u=http%3A//localhost/buzz/WebForm1.aspx&cls=wsi25&rid=c01"
1
1466
by: sreekeerthi | last post by:
hi friends...this is keerthi...i am doing a project where i want to redirect my page when ever the back button is clicked...for this i am using window.onbeforeunload method..and for page redirection i am using window.location and my code is as follows <html> <head> <script type="text/javascript"> var confirm = true; window.onbeforeunload = unload; function unload() { if(confirm)
41
3255
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to resolve this issue once and for all now. The problem might be PHP related but since I only develop applications using PHP, I'm not a hundred percent sure. Therefor I've taken the liberty to crosspost to comp.lang.php and alt.www.webmaster. I...
4
2805
by: damiensawyer | last post by:
Hi, I'm trying to do something in global.asax that I would have thought to be quite simple. Basically, any request at all should get sent to another page. I actually got the code below from a book. For some reason, it's not working. Can someone please tell me what I'm doing wrong? Thanks in advance,
3
1411
pradeepjain
by: pradeepjain | last post by:
hii guys, i am redirecting my website to an error page when it cannot connect to mysql database .because of this the url of the page gets changed to error page url .so the user will try to refresh the page but he still will be in the error page..I need to redirect such that when an error occurs the url must not change but the redirecting must happen .so that when a user refreshes the page when an error occurs .he will be able...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.