Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: simple serach --newbie question


Message #1 by "taherm@f... on Fri, 21 Sep 2001 11:18:00
my problem is :



i have an asp page whihc searches for an item code in the itemcode field 

and lets the user know if that product is available. so what i am doing is 

storing the value from a text box field to a variable 

dim item

item = request.querystring("itemcode")

and then i am checking for it in my table



rsProduct.movefirst

do while not rsProduct.eof

if item = rsProd.Fields.Item("itemcode").Value then

response.write "item found"

end if

rsProduct.movenext

loop



now what happens is it only searches for exact case.

suppose in my db th productcode is ARGENT3000 and if the user entered 

argent3000, it doent find it. i am using sqlserver and the datatype for 

item code is nvarchar.



plz let me knw of what shall i do in this case.



i would be greatfull to you ... and would appreciate any type of response.

Regards

Message #2 by "Hema R." <hema.r@s...> on Fri, 21 Sep 2001 16:12:12 +0530
Hi,



You could convert both item and request.querystring("itemcode") to

a single case before comparing.

Use lcase() or ucase().



regards

Hema



> -----Original Message-----

> From:	taherm@f... [SMTP:taherm@f...]

> Sent:	21 September Friday 2001 04:48 PM

> To:	ASP Web HowTo

> Subject:	[asp_web_howto] simple serach --newbie question

> 

> my problem is :

> 

> i have an asp page whihc searches for an item code in the itemcode field 

> and lets the user know if that product is available. so what i am doing is

> 

> storing the value from a text box field to a variable 

> dim item

> item = request.querystring("itemcode")

> and then i am checking for it in my table

> 

> rsProduct.movefirst

> do while not rsProduct.eof

> if item = rsProd.Fields.Item("itemcode").Value then

> response.write "item found"

> end if

> rsProduct.movenext

> loop

> 

> now what happens is it only searches for exact case.

> suppose in my db th productcode is ARGENT3000 and if the user entered 

> argent3000, it doent find it. i am using sqlserver and the datatype for 

> item code is nvarchar.

> 

> plz let me knw of what shall i do in this case.

> 

> i would be greatfull to you ... and would appreciate any type of response.

> Regards

> 



Message #3 by irfan.syed@g... on Fri, 21 Sep 2001 18:33:17 +0800

Try this, I htink it should work, at least will solve your case

sensitive search problem



rsProduct.movefirst

do while not rsProduct.eof

if UCASE(item) = UCASE(rsProd.Fields.Item("itemcode").Value) then

response.write "item found"

end if

rsProduct.movenext

loop















"taherm@f..." <taherm on 09/21/2001 07:18:00 PM



Please respond to "ASP Web HowTo" <asp_web_howto@p...>



To:   "ASP Web HowTo" <asp_web_howto@p...>

cc:    (bcc: Irfan H Syed/DHS/DHBG)

Subject:  [asp_web_howto] simple serach --newbie question







my problem is :



i have an asp page whihc searches for an item code in the itemcode

field

and lets the user know if that product is available. so what i am

doing is

storing the value from a text box field to a variable

dim item

item = request.querystring("itemcode")

and then i am checking for it in my table



rsProduct.movefirst

do while not rsProduct.eof

if item = rsProd.Fields.Item("itemcode").Value then

response.write "item found"

end if

rsProduct.movenext

loop



now what happens is it only searches for exact case.

suppose in my db th productcode is ARGENT3000 and if the user entered

argent3000, it doent find it. i am using sqlserver and the datatype

for

item code is nvarchar.



plz let me knw of what shall i do in this case.



i would be greatfull to you ... and would appreciate any type of

response.

Regards



Message #4 by "Taher Moiyed" <taherm@f...> on Fri, 21 Sep 2001 12:34:34 +0100
dear irfan

i have now encountered another problem

i have some prducts like HUB16 with numbers attached to it.

in my sqlserver i have set the datatype to nvarchar. i hae checked usign all

other datatypes but it doent work.



if the user eneters any product without numbers my asp page performs a

proper seach and returns results but say if teh user entered a correct

itemcode like HUB16 even after beign in the database the asp page does not

return any results.



plz let me knw of what to do.



regards

taher



-----Original Message-----

From: irfan.syed@g... [mailto:irfan.syed@g...]

Sent: 21 September 2001 11:33

To: ASP Web HowTo

Subject: [asp_web_howto] Re: simple serach --newbie question







Try this, I htink it should work, at least will solve your case

sensitive search problem



rsProduct.movefirst

do while not rsProduct.eof

if UCASE(item) = UCASE(rsProd.Fields.Item("itemcode").Value) then

response.write "item found"

end if

rsProduct.movenext

loop















"taherm@f..." <taherm on 09/21/2001 07:18:00 PM



Please respond to "ASP Web HowTo" <asp_web_howto@p...>



To:   "ASP Web HowTo" <asp_web_howto@p...>

cc:    (bcc: Irfan H Syed/DHS/DHBG)

Subject:  [asp_web_howto] simple serach --newbie question







my problem is :



i have an asp page whihc searches for an item code in the itemcode

field

and lets the user know if that product is available. so what i am

doing is

storing the value from a text box field to a variable

dim item

item = request.querystring("itemcode")

and then i am checking for it in my table



rsProduct.movefirst

do while not rsProduct.eof

if item = rsProd.Fields.Item("itemcode").Value then

response.write "item found"

end if

rsProduct.movenext

loop



now what happens is it only searches for exact case.

suppose in my db th productcode is ARGENT3000 and if the user entered

argent3000, it doent find it. i am using sqlserver and the datatype

for

item code is nvarchar.



plz let me knw of what shall i do in this case.



i would be greatfull to you ... and would appreciate any type of

response.

Regards







Message #5 by Mark Eckeard <meckeard2000@y...> on Fri, 21 Sep 2001 05:22:49 -0700 (PDT)
You could always insure that the data is always in

upper case.  Then, take the input from the user and

convert to upper case for your search:



dim item

item = UCASE(request.querystring("itemcode"))



It won't matter how the user types it in, it will

always be upper case.



Mark



--- "taherm@f..."

<taherm@f...> wrote:

> my problem is :

> 

> i have an asp page whihc searches for an item code

> in the itemcode field 

> and lets the user know if that product is available.

> so what i am doing is 

> storing the value from a text box field to a

> variable 

> dim item

> item = request.querystring("itemcode")

> and then i am checking for it in my table

> 

> rsProduct.movefirst

> do while not rsProduct.eof

> if item = rsProd.Fields.Item("itemcode").Value then

> response.write "item found"

> end if

> rsProduct.movenext

> loop

> 

> now what happens is it only searches for exact case.

> suppose in my db th productcode is ARGENT3000 and if

> the user entered 

> argent3000, it doent find it. i am using sqlserver

> and the datatype for 

> item code is nvarchar.

> 

> plz let me knw of what shall i do in this case.

> 

> i would be greatfull to you ... and would appreciate

> any type of response.

> Regards

> 


  Return to Index