473,386 Members | 1,715 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,386 software developers and data experts.

A simple code comparing querystring to recordset value

Hi

I am desperate for some help. I have a very simple piece of code that doesn't work.

I request a number from the query string
I request a number from a database (MS Access)

If one is bigger, display true, else, display false!!

Then, go to the next item and do the same until EOF/BOF

So, my code looks like
Expand|Select|Wrap|Line Numbers
  1. While ((RepeatAdvancedSearchResults__numRows <> 0) AND (NOT rsAdvancedSearchResults.EOF)) 
  2.  
  3.  
  4. if (rsAdvancedSearchResults.Fields.Item("MinContacts").Value) >= request.QueryString("contacts") then
  5. response.write("It worked")
  6. else
  7. response.write("It did NOT work")
  8. end if
  9. %>
  10.  
  11. SHOW INFORMATION
  12.  
  13. <% 
  14.   RepeatAdvancedSearchResults__index=RepeatAdvancedSearchResults__index+1
  15.   RepeatAdvancedSearchResults__numRows=RepeatAdvancedSearchResults__numRows-1
  16.   rsAdvancedSearchResults.MoveNext()
  17. Wend
  18. %>
The page loads as it should do, but it doesn't do the maths. Either every product is true, or every product is false.

I have tried converting the numbers into variables. Do I need to tell the computer the variable is an int??


Please help

Thanks

Dave
Oct 10 '07 #1
2 1880
The answer (I would normally remove the link/post, but I don't know how to, so instead of leaving it, I thought I would answer it)

Define the conditions with the SQL. So, I wrote

rsAdvancedSearchResults.Source = "SELECT * FROM GradParts where ((MinContacts <= " + replace (var_Contacts,"'","''") + ") and (MaxContacts >= " + replace (var_Contacts,"'","''") + "))

At first, it still wouldn't work.During the replace code, it is normally started with '" (please note the single quotation mark) which make it a string. Removing it made it an int!! (I think)

Dave
Oct 10 '07 #2
jhardman
3,406 Expert 2GB
At first, it still wouldn't work.During the replace code, it is normally started with '" (please note the single quotation mark) which make it a string. Removing it made it an int!! (I think)
Yes, that is how you show the difference tin SQL. unfortunately, VBScript doesn't work so well, and it is always assumed that anything sent via querystring is a string. Your first code could be adapted like this:
Expand|Select|Wrap|Line Numbers
  1. dim myNum
  2. myNum = cint(request.querystring("contacts"))
  3. if (rsAdvancedSearchResults.Fields.Item("MinContacts").Value) >= myNum then
the cint() function converts a string to an integer, then this value can be used for the comparison.

Jared
Oct 14 '07 #3

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

Similar topics

13
by: Samantha Smit | last post by:
Hi, I am trying to create a simple asp page that has one command button that updates a database. The URL of the page is like this: http://MyServer.com/Update.asp?UserName=Tom My asp code is...
0
by: collie | last post by:
Hi, I have an asp page that needs to create 2 different cookies: one for the admin and one for the user. The code that I have to work with was created by someone else. the page first requires to...
2
by: M P | last post by:
Can anyone help me find a code for Database Paging? I have seen some of it but its very hard for me to read, its too advance. Need to have a code with beginner to intermediate level. thanks, ...
2
by: dmiller23462 | last post by:
Hey guys, I'm back again....I've got the results displaying that I wanted but instead of having a "next" or "previous" link displayed I am getting the error msg below (I actually get the data that...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
15
by: gjoneshtfc | last post by:
Hello, I have a simple problem that I just cannot get my head around! I currently have the following line in my ASP recordset: Recordset1.Source = "SELECT * FROM MainTable ORDER BY Price ASC"...
1
by: ozzii | last post by:
Hi, Does anybody know how to parse the name value pairs in a querystring contained in a variable with asp? for those of you who might be confused, what i am trying to do is basically I have a...
1
by: RN1 | last post by:
Sometimes I find that though I am comparing 2 integers, the result turns out to be unexpected. For e.g. an ASP page encapsulates recordset paging. <% Dim iPage,iPageCounter ...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.