DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 17:35:39 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    am
          2    am
                 3    am


Proper way to use LIKE operator with SqlDataSource and control parameters in declarative markup?   
I'm trying to use LIKE operators in SqlDataSource with Control Parameters. 
The following should express my intent, but it does not work in the way I 
want it to (returns no results):

SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
'102') AND (byline LIKE '%@byline%')) OR ((categoryid = '102') AND (keywords 
LIKE '%@keywords%')) OR ((categoryid = '102') AND (keywords LIKE 
'%@jobid%'))  OR ((categoryid = '102') AND (title LIKE '%@keywords%'))">

Besides generating the string that should go with the SelectCommand 
programmatically, is there a way to make this work right declaratively?

Subbing in literal values returns a whole lot of results:

SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
'102') AND (byline LIKE '%president%')) OR ((categoryid = '102') AND 
(keywords LIKE '%president%')) OR ((categoryid = '102') AND (jobid LIKE 
'%president%'))  OR ((categoryid = '102') AND (title LIKE '%president%'))">

Help out there? MSDN managed newsgroup support should be linked to this 
account in, oh, 12 hours or so. :)

Thanks!

-KF
Date:Fri, 17 Aug 2007 17:35:39 -0700   Author:  

doesn't work even with "correct" SQL references Re: Proper way to use LIKE operator with SqlDataSource and control parameters in declarative markup?   
Yeah, I know that that first SQL statement seemed a little funny, but the 
"corrected" version doesn't help either:

SelectCommand="SELECT title, conid  FROM Contentitems WHERE ((categoryid = 
'102') AND (byline LIKE '%@byline%')) OR ((categoryid = '102') AND (keywords 
LIKE '%@keywords%')) OR ((categoryid = '102') AND (jobid LIKE '%@jobid%')) 
OR ((categoryid = '102') AND (title LIKE '%@title%'))">

<kenfine@nospam.nospam> wrote in message 
news:%23fQf6%23S4HHA.5316@TK2MSFTNGP04.phx.gbl...

> I'm trying to use LIKE operators in SqlDataSource with Control Parameters. 
> The following should express my intent, but it does not work in the way I 
> want it to (returns no results):
>
> SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
> '102') AND (byline LIKE '%@byline%')) OR ((categoryid = '102') AND 
> (keywords LIKE '%@keywords%')) OR ((categoryid = '102') AND (keywords LIKE 
> '%@jobid%'))  OR ((categoryid = '102') AND (title LIKE '%@keywords%'))">
>
> Besides generating the string that should go with the SelectCommand 
> programmatically, is there a way to make this work right declaratively?
>
> Subbing in literal values returns a whole lot of results:
>
> SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
> '102') AND (byline LIKE '%president%')) OR ((categoryid = '102') AND 
> (keywords LIKE '%president%')) OR ((categoryid = '102') AND (jobid LIKE 
> '%president%'))  OR ((categoryid = '102') AND (title LIKE 
> '%president%'))">
>
> Help out there? MSDN managed newsgroup support should be linked to this 
> account in, oh, 12 hours or so. :)
>
> Thanks!
>
> -KF
> 
Date:Fri, 17 Aug 2007 17:45:42 -0700   Author:  

SOLVED Re: doesn't work even with "correct" SQL references Re: Proper way to use LIKE operator with SqlDataSource and control parameters in declarative markup?   
This CAN be done from declarative code.

The answer is to use concatenation operators and single quotes around the 
percent symbols as follows:

SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
'102') AND (byline LIKE '%' + @byline + '%')) OR ((categoryid = '102') AND 
(keywords LIKE '%' + @keywords + '%')) OR ((categoryid = '102') AND (jobid 
LIKE '%' + @jobid + '%'))  OR ((categoryid = '102') AND (title LIKE '%' + 
@title + '%'))">


<kenfine@nospam.nospam> wrote in message 
news:OEVAiET4HHA.4584@TK2MSFTNGP03.phx.gbl...

>
> Yeah, I know that that first SQL statement seemed a little funny, but the 
> "corrected" version doesn't help either:
>
> SelectCommand="SELECT title, conid  FROM Contentitems WHERE ((categoryid = 
> '102') AND (byline LIKE '%@byline%')) OR ((categoryid = '102') AND 
> (keywords LIKE '%@keywords%')) OR ((categoryid = '102') AND (jobid LIKE 
> '%@jobid%')) OR ((categoryid = '102') AND (title LIKE '%@title%'))">
>
> <kenfine@nospam.nospam> wrote in message 
> news:%23fQf6%23S4HHA.5316@TK2MSFTNGP04.phx.gbl...
>> I'm trying to use LIKE operators in SqlDataSource with Control 
>> Parameters. The following should express my intent, but it does not work 
>> in the way I want it to (returns no results):
>>
>> SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
>> '102') AND (byline LIKE '%@byline%')) OR ((categoryid = '102') AND 
>> (keywords LIKE '%@keywords%')) OR ((categoryid = '102') AND (keywords 
>> LIKE '%@jobid%'))  OR ((categoryid = '102') AND (title LIKE 
>> '%@keywords%'))">
>>
>> Besides generating the string that should go with the SelectCommand 
>> programmatically, is there a way to make this work right declaratively?
>>
>> Subbing in literal values returns a whole lot of results:
>>
>> SelectCommand="SELECT title, conid FROM Contentitems WHERE ((categoryid = 
>> '102') AND (byline LIKE '%president%')) OR ((categoryid = '102') AND 
>> (keywords LIKE '%president%')) OR ((categoryid = '102') AND (jobid LIKE 
>> '%president%'))  OR ((categoryid = '102') AND (title LIKE 
>> '%president%'))">
>>
>> Help out there? MSDN managed newsgroup support should be linked to this 
>> account in, oh, 12 hours or so. :)
>>
>> Thanks!
>>
>> -KF
>>
>
> 
Date:Fri, 17 Aug 2007 19:07:56 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us