Connecting Tech Pros Worldwide
 
 
sign in | join about | help | sitemap
[ http://bytes.com/adLoader.php?parent=webdev
DaveRook's Avatar

Wildcard and intergers


Question posted by: DaveRook (Newbie) on October 9th, 2008 05:04 PM
Hi

I have a simple piece of code which will not accept the wild card!

My SQL looks like

Expand|Select|Wrap|Line Numbers
<% if Request.QueryString("num")<>"" then Var_Number = Request.QueryString("num") else Var_Number="%" end if %>     <%   Dim rs05 Dim rs05_numRows   Set rs05 = Server.CreateObject("ADODB.Recordset") rs05.ActiveConnection = conn_05 rs05.Source = "SELECT *  FROM 05 WHERE ((MinContacts <= "+ Replace(Var_Number, "'", "''")+") AND (MaxContacts >= "+ Replace(Var_Number, "'", "''")+"))" rs05.CursorType = 0 rs05.CursorLocation = 2 rs05.LockType = 1 rs05.Open() %>


Let's pretend the user doesn't specify a number and so the program uses the wildcard!

If I enter

Var_Number=%

I get the message Invalid character

If I include spech marks

Var_Number="%"

I get: Microsoft JET Database Engine error '80040e14'
((MinContacts <= %) AND (MaxContacts >= %))

I have looked online, and it says the program doesn't know how to handle % as it's probably looking for an int, but I don't know how to correct it!

Thanks for any help

Dave
post reply
Quote | Subscribe
3 Answers Posted
codegecko's Avatar
Moderator - 329 Posts
#2: Re: Wildcard and intergers

Hi Dave,

The answer to your question is remarkably simple - wildcards don't work with numbers! You'd have to move your If block to surround your SQL construct like so:
Expand|Select|Wrap|Line Numbers
<% Dim rs05 Dim rs05_numRows   Set rs05 = Server.CreateObject("ADODB.Recordset") rs05.ActiveConnection = conn_05 rs05.Source = "SELECT *  FROM 05"  If Request.QueryString("num")<>"" Then     Var_Number = Request.QueryString("num")     rs05.Source = rs05.Source + " WHERE ((MinContacts <= "+ Replace(Var_Number, "'", "''")+") AND (MaxContacts >= "+ Replace(Var_Number, "'", "''")+"))" End If rs05.CursorType = 0 rs05.CursorLocation = 2 rs05.LockType = 1 rs05.Open() %>


Hope this helps.

medicineworker
DaveRook's Avatar
Newbie - 29 Posts
#3: Re: Wildcard and intergers

medicineworker,

Thank you for your suggestion and help. This will now allow me to progress with this.

Thank you,

Dave
codegecko's Avatar
Moderator - 329 Posts
#4: Re: Wildcard and intergers

You're welcome Dave :-)

med
Reply
Not the answer you were looking for? Post your question . . .
196,219 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,219 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top ASP Contributors

[ http://bytes.com/adLoader.php?parent=webdev


You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser