using LIKE %% with controlparameter

M

musosdev

Hi

I have a GridView using an SQLDataSource on my aspx form.

I've got the control parameter in the SQL as follows...

... WHERE ([ProjectName] LIKE @search)

and my control parameter is declared as follows...

<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" PropertyName="Text"
DefaultValue="" Name="search" />
</SelectParameters>

However, I need to be have my SQL be have LIKE % % around my control
parameter. Kinda like...

... WHERE ([ProjectName] LIKE %@search%)

But I can't get any variation on this to work. How can I make sure that my
query returns any row where ProjectName containts whatever is in @search ?!

Thanks,


Dan
 
M

musosdev

Tahir,

That worked great, thanks. Probably the only variation I didn't try!

Cheers!


Dan

Tahir said:
hi,

did you try this?
WHERE ([ProjectName] LIKE '%' + @search + '%')



iletisinde şunu yazdı said:
Hi

I have a GridView using an SQLDataSource on my aspx form.

I've got the control parameter in the SQL as follows...

.. WHERE ([ProjectName] LIKE @search)

and my control parameter is declared as follows...

<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" PropertyName="Text"
DefaultValue="" Name="search" />
</SelectParameters>

However, I need to be have my SQL be have LIKE % % around my control
parameter. Kinda like...

.. WHERE ([ProjectName] LIKE %@search%)

But I can't get any variation on this to work. How can I make sure that my
query returns any row where ProjectName containts whatever is in @search
?!

Thanks,


Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top