passing wildcard criteria

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
Wendy Parry [ So, 12 Februar 2006 13:06 ] [ ID #1184799 ]

Re: passing wildcard criteria

"Wendy Parry" <wendy.parry [at] lotusblossom.org.uk> wrote in message
news:dsn8cn$dlu$1 [at] 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
Roger Hembury [ So, 12 Februar 2006 13:30 ] [ ID #1184800 ]

Re: passing wildcard criteria

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)
exjxw.hannivoort [ So, 12 Februar 2006 13:20 ] [ ID #1184801 ]

Re: passing wildcard criteria

Roger Hembury wrote:
> "Wendy Parry" <wendy.parry [at] lotusblossom.org.uk> wrote in message
> news:dsn8cn$dlu$1 [at] 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...
Wendy Parry [ So, 12 Februar 2006 13:42 ] [ ID #1184802 ]
Webserver » microsoft.public.inetserver.asp.db » passing wildcard criteria

Vorheriges Thema: one to many / master detail issue
Nächstes Thema: Problem with client side active x accessing access database on web server