473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Redirecting a page

147 100+
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 1496
DrBunchman
979 Expert 512MB
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
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...
0
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...
1
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
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...
4
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...
4
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...
1
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...
41
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...
4
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.