passing wildcard criteria

passing wildcard criteria

am 12.02.2006 13:06:47 von Wendy Parry

Hi,
I'm having a little trouble using the SQL LIKE clause with asp.net to an
Access Database...

Dim strSQL as String = "SELECT * FROM tblDickerExtensions WHERE Surname
" & " LIKE " & criteria & "*"

I just can't get the " & ' syntax correct, I'm sure it's a 2 second
thing for you guys...

thanks in advance for help

Re: passing wildcard criteria

am 12.02.2006 13:20:59 von exjxw.hannivoort

Wendy Parry wrote on 12 feb 2006 in microsoft.public.inetserver.asp.db:

> Hi,
> I'm having a little trouble using the SQL LIKE clause with asp.net to an
> Access Database...
>
> Dim strSQL as String = "SELECT * FROM tblDickerExtensions WHERE Surname
> " & " LIKE " & criteria & "*"

"as String"
not in asp-vbs

" & criteria & "*"
must be quoted

Dim strSQL,criteria
criterium = "bl?h*"
strSQL = "SELECT * FROM tblX WHERE Sn LIKE '" & criterium & "'"



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

Re: passing wildcard criteria

am 12.02.2006 13:30:01 von Roger Hembury

"Wendy Parry" wrote in message
news:dsn8cn$dlu$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
> Hi,
> I'm having a little trouble using the SQL LIKE clause with asp.net to an
> Access Database...
>
> Dim strSQL as String = "SELECT * FROM tblDickerExtensions WHERE Surname "
> & " LIKE " & criteria & "*"
>
> I just can't get the " & ' syntax correct, I'm sure it's a 2 second thing
> for you guys...
>
> thanks in advance for help

Try changing it to

Dim strSQL as string = "SELECT * FROM tblDickerExtensions WHERE Surname LIKE
'%" & criteria & "%'"

Note the single quote ' before and after the %

Don't know if this will work in asp.net but it works with classic asp

Roger

Re: passing wildcard criteria

am 12.02.2006 13:42:00 von Wendy Parry

Roger Hembury wrote:
> "Wendy Parry" wrote in message
> news:dsn8cn$dlu$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
>
>>Hi,
>>I'm having a little trouble using the SQL LIKE clause with asp.net to an
>>Access Database...
>>
>>Dim strSQL as String = "SELECT * FROM tblDickerExtensions WHERE Surname "
>>& " LIKE " & criteria & "*"
>>
>>I just can't get the " & ' syntax correct, I'm sure it's a 2 second thing
>>for you guys...
>>
>>thanks in advance for help
>
>
> Try changing it to
>
> Dim strSQL as string = "SELECT * FROM tblDickerExtensions WHERE Surname LIKE
> '%" & criteria & "%'"
>
> Note the single quote ' before and after the %
>
> Don't know if this will work in asp.net but it works with classic asp
>
> Roger
>
>
Thanks Roger, that worked a treat...