Search Query Problem

Search Query Problem

am 02.05.2007 10:01:13 von Simon Gare

Hi,

have a search.asp page with results.asp page drawing data from an SQL db,
problem is the user has to type the whole field value into the search box to
retrieve the value on results.asp, what I need is to type in just a few
characters e.g. at the moment to search for all pickups at Heathrow Terminal
1 the user has to type in

Heathrow Terminal 1

When really I just want them to type in

Heathrow or even Heath etc.

Query below

SELECT * FROM booking_form WHERE AirportStation LIKE '" +
Replace(BookingForm__varAirportStation, "'", "''") + "'


anyone help?

Simon
--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk

Re: Search Query Problem

am 02.05.2007 10:13:54 von Michal

SELECT * FROM booking_form WHERE AirportStation LIKE ('%" +
Replace(BookingForm__varAirportStation, "'", "''") + "%')"

should do it

On 2 Mai, 10:01, "Simon Gare" wrote:
> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL db,
> problem is the user has to type the whole field value into the search box to
> retrieve the value on results.asp, what I need is to type in just a few
> characters e.g. at the moment to search for all pickups at Heathrow Terminal
> 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'
>
> anyone help?
>
> Simon
> --
> Simon Gare
> The Gare Group Limited
>
> website: www.thegaregroup.co.uk
> website: www.privatehiresolutions.co.uk

Re: Search Query Problem

am 02.05.2007 10:17:34 von exjxw.hannivoort

Simon Gare wrote on 02 mei 2007 in
microsoft.public.inetserver.asp.general:

> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL
> db, problem is the user has to type the whole field value into the
> search box to retrieve the value on results.asp, what I need is to
> type in just a few characters e.g. at the moment to search for all
> pickups at Heathrow Terminal 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'

With "LIKE" you only would have to add a wildcard character.

SELECT * FROM booking_form WHERE AirportStation LIKE '" +_
yourSearchInput + "%" + "'

=============

"Heathrow Te" + "%"

will select:

Heathrow Terminal 1
Heathrow Terminal 2
Heathrow Terminal 3
Heathrow Terminal 4
Heathrow Terminal 5 [?]


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Search Query Problem

am 02.05.2007 10:28:05 von Simon Gare

Thanks all worked perfectly.

Simon

Re: Search Query Problem

am 02.05.2007 11:28:45 von Simon Gare

Just came across a problem, when searching the date field it returns
nothing, current entry format is

dd/mm/yyyy hh:mm:ss
02/05/2007 10:26:00

when I search for 02/05/2007 nothing is returned even though I have the % in
place.

All other search criteria is working ok?

Simon


"Simon Gare" wrote in message
news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL db,
> problem is the user has to type the whole field value into the search box
to
> retrieve the value on results.asp, what I need is to type in just a few
> characters e.g. at the moment to search for all pickups at Heathrow
Terminal
> 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'
>
>
> anyone help?
>
> Simon
> --
> Simon Gare
> The Gare Group Limited
>
> website: www.thegaregroup.co.uk
> website: www.privatehiresolutions.co.uk
>
>

Re: Search Query Problem

am 02.05.2007 11:53:24 von Michal

i am not sure but i think that like is not working on data columns ...
you should be fine with
WHERE datCol = '02/05/2007'

On 2 Mai, 11:28, "Simon Gare" wrote:
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>
> when I search for 02/05/2007 nothing is returned even though I have the % in
> place.
>
> All other search criteria is working ok?
>
> Simon
>
> "Simon Gare" wrote in message
>
> news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
>
>
>
> > Hi,
>
> > have a search.asp page with results.asp page drawing data from an SQL db,
> > problem is the user has to type the whole field value into the search box
> to
> > retrieve the value on results.asp, what I need is to type in just a few
> > characters e.g. at the moment to search for all pickups at Heathrow
> Terminal
> > 1 the user has to type in
>
> > Heathrow Terminal 1
>
> > When really I just want them to type in
>
> > Heathrow or even Heath etc.
>
> > Query below
>
> > SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> > Replace(BookingForm__varAirportStation, "'", "''") + "'
>
> > anyone help?
>
> > Simon
> > --
> > Simon Gare
> > The Gare Group Limited
>
> > website: www.thegaregroup.co.uk
> > website: www.privatehiresolutions.co.uk- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Re: Search Query Problem

am 02.05.2007 12:02:25 von Simon Gare

but we retrieve the value from a querystring that is entered on a search
page

BookingForm__varID = Request.Querystring DATE2

TimeOfBooking LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%'

but returns no values doesn't matter what format you put it in either, will
retrieve values when the format is correct though which is no good to us.

02/05/2007 11:02:35 etc




"michal" wrote in message
news:1178099604.508166.231810@o5g2000hsb.googlegroups.com...
> i am not sure but i think that like is not working on data columns ...
> you should be fine with
> WHERE datCol = '02/05/2007'
>
> On 2 Mai, 11:28, "Simon Gare" wrote:
> > Just came across a problem, when searching the date field it returns
> > nothing, current entry format is
> >
> > dd/mm/yyyy hh:mm:ss
> > 02/05/2007 10:26:00
> >
> > when I search for 02/05/2007 nothing is returned even though I have the
% in
> > place.
> >
> > All other search criteria is working ok?
> >
> > Simon
> >
> > "Simon Gare" wrote in message
> >
> > news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
> >
> >
> >
> > > Hi,
> >
> > > have a search.asp page with results.asp page drawing data from an SQL
db,
> > > problem is the user has to type the whole field value into the search
box
> > to
> > > retrieve the value on results.asp, what I need is to type in just a
few
> > > characters e.g. at the moment to search for all pickups at Heathrow
> > Terminal
> > > 1 the user has to type in
> >
> > > Heathrow Terminal 1
> >
> > > When really I just want them to type in
> >
> > > Heathrow or even Heath etc.
> >
> > > Query below
> >
> > > SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> > > Replace(BookingForm__varAirportStation, "'", "''") + "'
> >
> > > anyone help?
> >
> > > Simon
> > > --
> > > Simon Gare
> > > The Gare Group Limited
> >
> > > website: www.thegaregroup.co.uk
> > > website: www.privatehiresolutions.co.uk- Zitierten Text ausblenden -
> >
> > - Zitierten Text anzeigen -
>
>

Re: Search Query Problem

am 02.05.2007 12:03:43 von Mike Brind

Michal is correct. LIKE doesn't work with datetime. You will have to use
Between to find datetimes in a range. If you want to find items with
today's date, your range will be from 02/05/2007 00:00:00 to 02/05/2007
23:59:59.

--
Mike Brind

"Simon Gare" wrote in message
news:ux8L7yJjHHA.4552@TK2MSFTNGP04.phx.gbl...
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>
> when I search for 02/05/2007 nothing is returned even though I have the %
> in
> place.
>
> All other search criteria is working ok?
>
> Simon
>
>
> "Simon Gare" wrote in message
> news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> have a search.asp page with results.asp page drawing data from an SQL db,
>> problem is the user has to type the whole field value into the search box
> to
>> retrieve the value on results.asp, what I need is to type in just a few
>> characters e.g. at the moment to search for all pickups at Heathrow
> Terminal
>> 1 the user has to type in
>>
>> Heathrow Terminal 1
>>
>> When really I just want them to type in
>>
>> Heathrow or even Heath etc.
>>
>> Query below
>>
>> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
>> Replace(BookingForm__varAirportStation, "'", "''") + "'
>>
>>
>> anyone help?
>>
>> Simon
>> --
>> Simon Gare
>> The Gare Group Limited
>>
>> website: www.thegaregroup.co.uk
>> website: www.privatehiresolutions.co.uk
>>
>>
>
>

Re: Search Query Problem

am 02.05.2007 12:19:24 von Simon Gare

ok, so if I want to find all entries an the results page with the date
specified in the querystring which is entered manually by the user on the
search page how do I go about that? do I use 2 BETWEEN statements ie

Select * FROM BookingForm WHERE DATE2 BETWEEN Request.Querystring("DATE2")
and BETWEEN Request.Querystring("DATE2")

something like that?

Simon


"Mike Brind" wrote in message
news:us2kmEKjHHA.3928@TK2MSFTNGP03.phx.gbl...
> Michal is correct. LIKE doesn't work with datetime. You will have to use
> Between to find datetimes in a range. If you want to find items with
> today's date, your range will be from 02/05/2007 00:00:00 to 02/05/2007
> 23:59:59.
>
> --
> Mike Brind
>
> "Simon Gare" wrote in message
> news:ux8L7yJjHHA.4552@TK2MSFTNGP04.phx.gbl...
> > Just came across a problem, when searching the date field it returns
> > nothing, current entry format is
> >
> > dd/mm/yyyy hh:mm:ss
> > 02/05/2007 10:26:00
> >
> > when I search for 02/05/2007 nothing is returned even though I have the
%
> > in
> > place.
> >
> > All other search criteria is working ok?
> >
> > Simon
> >
> >
> > "Simon Gare" wrote in message
> > news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
> >> Hi,
> >>
> >> have a search.asp page with results.asp page drawing data from an SQL
db,
> >> problem is the user has to type the whole field value into the search
box
> > to
> >> retrieve the value on results.asp, what I need is to type in just a few
> >> characters e.g. at the moment to search for all pickups at Heathrow
> > Terminal
> >> 1 the user has to type in
> >>
> >> Heathrow Terminal 1
> >>
> >> When really I just want them to type in
> >>
> >> Heathrow or even Heath etc.
> >>
> >> Query below
> >>
> >> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> >> Replace(BookingForm__varAirportStation, "'", "''") + "'
> >>
> >>
> >> anyone help?
> >>
> >> Simon
> >> --
> >> Simon Gare
> >> The Gare Group Limited
> >>
> >> website: www.thegaregroup.co.uk
> >> website: www.privatehiresolutions.co.uk
> >>
> >>
> >
> >
>
>

Re: Search Query Problem

am 02.05.2007 12:40:00 von reb01501

Simon Gare wrote:
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>
http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Search Query Problem

am 02.05.2007 12:47:05 von Mike Brind

If the likely value of Request.QueryString("yourdate") is eg 02/05/2007,
then the query would be

Select * From BookingForm Where datefield Between '" &
Request.QueryString("yourdate") & " 00:00:00' AND '" &
Request.QueryString("yourdate") & " 23:59:59'

--
Mike

"Simon Gare" wrote in message
news:uYVmhOKjHHA.4676@TK2MSFTNGP02.phx.gbl...
> ok, so if I want to find all entries an the results page with the date
> specified in the querystring which is entered manually by the user on the
> search page how do I go about that? do I use 2 BETWEEN statements ie
>
> Select * FROM BookingForm WHERE DATE2 BETWEEN Request.Querystring("DATE2")
> and BETWEEN Request.Querystring("DATE2")
>
> something like that?
>
> Simon
>
>
> "Mike Brind" wrote in message
> news:us2kmEKjHHA.3928@TK2MSFTNGP03.phx.gbl...
>> Michal is correct. LIKE doesn't work with datetime. You will have to
>> use
>> Between to find datetimes in a range. If you want to find items with
>> today's date, your range will be from 02/05/2007 00:00:00 to 02/05/2007
>> 23:59:59.
>>
>> --
>> Mike Brind
>>
>> "Simon Gare" wrote in message
>> news:ux8L7yJjHHA.4552@TK2MSFTNGP04.phx.gbl...
>> > Just came across a problem, when searching the date field it returns
>> > nothing, current entry format is
>> >
>> > dd/mm/yyyy hh:mm:ss
>> > 02/05/2007 10:26:00
>> >
>> > when I search for 02/05/2007 nothing is returned even though I have the
> %
>> > in
>> > place.
>> >
>> > All other search criteria is working ok?
>> >
>> > Simon
>> >
>> >
>> > "Simon Gare" wrote in message
>> > news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
>> >> Hi,
>> >>
>> >> have a search.asp page with results.asp page drawing data from an SQL
> db,
>> >> problem is the user has to type the whole field value into the search
> box
>> > to
>> >> retrieve the value on results.asp, what I need is to type in just a
>> >> few
>> >> characters e.g. at the moment to search for all pickups at Heathrow
>> > Terminal
>> >> 1 the user has to type in
>> >>
>> >> Heathrow Terminal 1
>> >>
>> >> When really I just want them to type in
>> >>
>> >> Heathrow or even Heath etc.
>> >>
>> >> Query below
>> >>
>> >> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
>> >> Replace(BookingForm__varAirportStation, "'", "''") + "'
>> >>
>> >>
>> >> anyone help?
>> >>
>> >> Simon
>> >> --
>> >> Simon Gare
>> >> The Gare Group Limited
>> >>
>> >> website: www.thegaregroup.co.uk
>> >> website: www.privatehiresolutions.co.uk
>> >>
>> >>
>> >
>> >
>>
>>
>
>

Re: Search Query Problem

am 02.05.2007 15:48:11 von Simon Gare

Thanks Mike, works ok when looking for a date but upsets the other search
criteria, SQL Query looks at 1 value in the querystring and compares across
many fields


SELECT * FROM booking_form WHERE ID LIKE '" + Replace(BookingForm__varID,
"'", "''") + "' OR TimeOfBooking BETWEEN '" + Replace(BookingForm__varID,
"'", "''") + " 00:00:00' AND '" + Replace(BookingForm__varID, "'", "''") + "
23:59:59' OR PAX_NAME1 LIKE '%" + Replace(BookingForm__varID, "'", "''") +
"%' OR COLL_STREET LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%'
OR COLL_POST_CODE LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%' OR
MOBILE_NO LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%' OR
COLL_BUILDING_NAME_NO LIKE '%" + Replace(BookingForm__varID, "'", "''") +
"%' ORDER BY TimeOfBooking DESC"


When i put in the date it works fine but if i put in a name which looks in
PAX_NAME1 field the error reads

Syntax error converting datetime from character string.


Any ideas?

Simon


"Mike Brind" wrote in message
news:%231GqxcKjHHA.1900@TK2MSFTNGP04.phx.gbl...
> If the likely value of Request.QueryString("yourdate") is eg 02/05/2007,
> then the query would be
>
> Select * From BookingForm Where datefield Between '" &
> Request.QueryString("yourdate") & " 00:00:00' AND '" &
> Request.QueryString("yourdate") & " 23:59:59'
>
> --
> Mike
>
> "Simon Gare" wrote in message
> news:uYVmhOKjHHA.4676@TK2MSFTNGP02.phx.gbl...
> > ok, so if I want to find all entries an the results page with the date
> > specified in the querystring which is entered manually by the user on
the
> > search page how do I go about that? do I use 2 BETWEEN statements ie
> >
> > Select * FROM BookingForm WHERE DATE2 BETWEEN
Request.Querystring("DATE2")
> > and BETWEEN Request.Querystring("DATE2")
> >
> > something like that?
> >
> > Simon
> >
> >
> > "Mike Brind" wrote in message
> > news:us2kmEKjHHA.3928@TK2MSFTNGP03.phx.gbl...
> >> Michal is correct. LIKE doesn't work with datetime. You will have to
> >> use
> >> Between to find datetimes in a range. If you want to find items with
> >> today's date, your range will be from 02/05/2007 00:00:00 to
02/05/2007
> >> 23:59:59.
> >>
> >> --
> >> Mike Brind
> >>
> >> "Simon Gare" wrote in message
> >> news:ux8L7yJjHHA.4552@TK2MSFTNGP04.phx.gbl...
> >> > Just came across a problem, when searching the date field it returns
> >> > nothing, current entry format is
> >> >
> >> > dd/mm/yyyy hh:mm:ss
> >> > 02/05/2007 10:26:00
> >> >
> >> > when I search for 02/05/2007 nothing is returned even though I have
the
> > %
> >> > in
> >> > place.
> >> >
> >> > All other search criteria is working ok?
> >> >
> >> > Simon
> >> >
> >> >
> >> > "Simon Gare" wrote in message
> >> > news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
> >> >> Hi,
> >> >>
> >> >> have a search.asp page with results.asp page drawing data from an
SQL
> > db,
> >> >> problem is the user has to type the whole field value into the
search
> > box
> >> > to
> >> >> retrieve the value on results.asp, what I need is to type in just a
> >> >> few
> >> >> characters e.g. at the moment to search for all pickups at Heathrow
> >> > Terminal
> >> >> 1 the user has to type in
> >> >>
> >> >> Heathrow Terminal 1
> >> >>
> >> >> When really I just want them to type in
> >> >>
> >> >> Heathrow or even Heath etc.
> >> >>
> >> >> Query below
> >> >>
> >> >> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> >> >> Replace(BookingForm__varAirportStation, "'", "''") + "'
> >> >>
> >> >>
> >> >> anyone help?
> >> >>
> >> >> Simon
> >> >> --
> >> >> Simon Gare
> >> >> The Gare Group Limited
> >> >>
> >> >> website: www.thegaregroup.co.uk
> >> >> website: www.privatehiresolutions.co.uk
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>

Re: Search Query Problem

am 03.05.2007 09:57:37 von Mike Brind

Deary me. Just a glance at that SQL string makes me faint.

Try taking all those replace operations out of the concatention. Do them
before you build your SQL string. Better still, use parameter markers or
stored procedures.

Mike

"Simon Gare" wrote in message
news:uo3XMDMjHHA.1216@TK2MSFTNGP03.phx.gbl...
> Thanks Mike, works ok when looking for a date but upsets the other search
> criteria, SQL Query looks at 1 value in the querystring and compares
> across
> many fields
>
>
> SELECT * FROM booking_form WHERE ID LIKE '" +
> Replace(BookingForm__varID,
> "'", "''") + "' OR TimeOfBooking BETWEEN '" + Replace(BookingForm__varID,
> "'", "''") + " 00:00:00' AND '" + Replace(BookingForm__varID, "'", "''") +
> "
> 23:59:59' OR PAX_NAME1 LIKE '%" + Replace(BookingForm__varID, "'", "''") +
> "%' OR COLL_STREET LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%'
> OR COLL_POST_CODE LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%'
> OR
> MOBILE_NO LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%' OR
> COLL_BUILDING_NAME_NO LIKE '%" + Replace(BookingForm__varID, "'", "''") +
> "%' ORDER BY TimeOfBooking DESC"
>
>
> When i put in the date it works fine but if i put in a name which looks in
> PAX_NAME1 field the error reads
>
> Syntax error converting datetime from character string.
>
>
> Any ideas?
>
> Simon
>
>
> "Mike Brind" wrote in message
> news:%231GqxcKjHHA.1900@TK2MSFTNGP04.phx.gbl...
>> If the likely value of Request.QueryString("yourdate") is eg 02/05/2007,
>> then the query would be
>>
>> Select * From BookingForm Where datefield Between '" &
>> Request.QueryString("yourdate") & " 00:00:00' AND '" &
>> Request.QueryString("yourdate") & " 23:59:59'
>>
>> --
>> Mike
>>
>> "Simon Gare" wrote in message
>> news:uYVmhOKjHHA.4676@TK2MSFTNGP02.phx.gbl...
>> > ok, so if I want to find all entries an the results page with the date
>> > specified in the querystring which is entered manually by the user on
> the
>> > search page how do I go about that? do I use 2 BETWEEN statements ie
>> >
>> > Select * FROM BookingForm WHERE DATE2 BETWEEN
> Request.Querystring("DATE2")
>> > and BETWEEN Request.Querystring("DATE2")
>> >
>> > something like that?
>> >
>> > Simon
>> >
>> >
>> > "Mike Brind" wrote in message
>> > news:us2kmEKjHHA.3928@TK2MSFTNGP03.phx.gbl...
>> >> Michal is correct. LIKE doesn't work with datetime. You will have to
>> >> use
>> >> Between to find datetimes in a range. If you want to find items with
>> >> today's date, your range will be from 02/05/2007 00:00:00 to
> 02/05/2007
>> >> 23:59:59.
>> >>
>> >> --
>> >> Mike Brind
>> >>
>> >> "Simon Gare" wrote in message
>> >> news:ux8L7yJjHHA.4552@TK2MSFTNGP04.phx.gbl...
>> >> > Just came across a problem, when searching the date field it returns
>> >> > nothing, current entry format is
>> >> >
>> >> > dd/mm/yyyy hh:mm:ss
>> >> > 02/05/2007 10:26:00
>> >> >
>> >> > when I search for 02/05/2007 nothing is returned even though I have
> the
>> > %
>> >> > in
>> >> > place.
>> >> >
>> >> > All other search criteria is working ok?
>> >> >
>> >> > Simon
>> >> >
>> >> >
>> >> > "Simon Gare" wrote in message
>> >> > news:etrCUBJjHHA.4064@TK2MSFTNGP02.phx.gbl...
>> >> >> Hi,
>> >> >>
>> >> >> have a search.asp page with results.asp page drawing data from an
> SQL
>> > db,
>> >> >> problem is the user has to type the whole field value into the
> search
>> > box
>> >> > to
>> >> >> retrieve the value on results.asp, what I need is to type in just a
>> >> >> few
>> >> >> characters e.g. at the moment to search for all pickups at Heathrow
>> >> > Terminal
>> >> >> 1 the user has to type in
>> >> >>
>> >> >> Heathrow Terminal 1
>> >> >>
>> >> >> When really I just want them to type in
>> >> >>
>> >> >> Heathrow or even Heath etc.
>> >> >>
>> >> >> Query below
>> >> >>
>> >> >> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
>> >> >> Replace(BookingForm__varAirportStation, "'", "''") + "'
>> >> >>
>> >> >>
>> >> >> anyone help?
>> >> >>
>> >> >> Simon
>> >> >> --
>> >> >> Simon Gare
>> >> >> The Gare Group Limited
>> >> >>
>> >> >> website: www.thegaregroup.co.uk
>> >> >> website: www.privatehiresolutions.co.uk
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>

Re: Search Query Problem

am 03.05.2007 12:04:46 von reb01501

Simon Gare wrote:
> Thanks Mike, works ok when looking for a date but upsets the other
> search criteria, SQL Query looks at 1 value in the querystring and
> compares across many fields
>
Well, forget this idea. it cannot work. You cannot search a column with one
datatype using a value with an incompatible datatype. You will have to look
at the value supplied by the user and decide which columns to include in the
WHERE clause.
Personally, I would provide the user a means of indicating what type of data
is being supplied (a dropdown, or some radio buttons). In the responding
page, first validate that the data supplied for the search can be coerced
into the selected data type, returning an error to the user if it cannot be.
Once you have determined that the user has supplied compatible data and data
type, build your WHERE clause only including the columns that are compatible
with the selected data type.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Search Query Problem

am 03.05.2007 14:53:36 von Mike Brind

"Bob Barrows [MVP]" wrote in message
news:OT9L1pWjHHA.4676@TK2MSFTNGP02.phx.gbl...
> Simon Gare wrote:
>> Thanks Mike, works ok when looking for a date but upsets the other
>> search criteria, SQL Query looks at 1 value in the querystring and
>> compares across many fields
>>
> Well, forget this idea. it cannot work. You cannot search a column with
> one datatype using a value with an incompatible datatype.

I was so distracted by all the Replace() operations going on, I missed the
fact that Simon was using the same value for all the filters.