473,408 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Problem with asp:SqlDataSource LIKE condition with acute caracters

I have a table "tblCards" with a field "Titre" that contain french
words (Hébert, Gagné, Hélène, etc....) in an database with
SQLEXPRESS 2005.

I have used the asp:SqlDataSource to filter the SELECT statement
according to a Textbox the user can type into. When used with the LIKE
condition using any acute caracters the SELECT statement return
nothing, unless the acute caracters is replaced with an ampersand "%".
Even the underscore "_" does not work! I have tried my logic with SQL
2000 and it's working just fine. Here the setup I have:

<asp:SqlDataSource SelectCommand="SELECT * FROM [tblCards] WHERE
([Titre] LIKE '%' + @Search + '%')>
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" Name="Search"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

Now if I type a word like "Hébert" in the "txtSearch" Textbox nothing
is returned. But if I type "H%bert" it's working. Also typing "H_bert"
does not work!?!

Is this standard behavior or am I doing something wrong? Please help!

Alain

Jan 9 '06 #1
2 5171
al*********@gmail.com wrote:
I have a table "tblCards" with a field "Titre" that contain french
words (Hébert, Gagné, Hélène, etc....) in an database with
SQLEXPRESS 2005.

I have used the asp:SqlDataSource to filter the SELECT statement
according to a Textbox the user can type into. When used with the LIKE
condition using any acute caracters the SELECT statement return
nothing, unless the acute caracters is replaced with an ampersand "%".
Even the underscore "_" does not work! I have tried my logic with SQL
2000 and it's working just fine. Here the setup I have:

<asp:SqlDataSource SelectCommand="SELECT * FROM [tblCards] WHERE
([Titre] LIKE '%' + @Search + '%')>
<SelectParameters>
<asp:ControlParameter ControlID="txtSearch" Name="Search"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

Now if I type a word like "Hébert" in the "txtSearch" Textbox nothing
is returned. But if I type "H%bert" it's working. Also typing "H_bert"
does not work!?!

Is this standard behavior or am I doing something wrong? Please help!

Alain

3 things:

1) What's with the LIKE '%' + @Search + '%' ? No need for odd string
concatenation... That should be LIKE '%@Search%' - I'm surprised that
doesn't even throw an exception...

2) é isn't a "normal" character in html (well, depending on encoding
type used), it's represented by é or &eacute; - you don't want that
as-is in your SQL query's parameter. You'll have to re-convert those
first (I'd look into ISO-8859-1/windows-1252/UTF-8 character encoding too).

3) No need to double post at such short interval...
Jan 9 '06 #2
> 1) What's with the LIKE '%' + @Search + '%' ? No need for odd string
concatenation... That should be LIKE '%@Search%' - I'm surprised that
doesn't even throw an exception...
That's what is being created automatically with the SqlDataSource Task
"Configure Data Source..." when you specify a WHERE condition based on an
existing control. I did not create this, only using it. In fact doing it
your way breaks it. No exceptions is thrown, it just return nothing all the
time.
2) é isn't a "normal" character in html (well, depending on encoding type
used), it's represented by é or &eacute; - you don't want that as-is
in your SQL query's parameter. You'll have to re-convert those first (I'd
look into ISO-8859-1/windows-1252/UTF-8 character encoding too).
After rebooting the server everything is working correctly now. I supposed I
should have rebooted after changing the field collation to "FRENCH_CI_AI"
instead of just restarting SQLEXPRESS.
3) No need to double post at such short interval...


Oups, sorry for that, it's my error and my eagerness...
Jan 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
0
by: Alain Hogue | last post by:
When I try to use "%" with the LIKE command it return nothing if they are an acute charater in the search string. For example if I have a field named "Title" containing words like "Hébert, Gagné,...
1
by: Arne Garvander | last post by:
How do I set parameters from code for a SqlDataSource? -- Arne Garvander (I program VB.Net for fun and C# to get paid.)
11
by: tbh | last post by:
is it possible in the ConnectionString of an asp:SqlDataSource construction to refer to a variable i define at the top of my ASPX script and initialize, for example, during Page_Init()? (the...
4
by: saturnius | last post by:
Hello, I have to save the data from a gridview as XML file. The code is shown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or...
1
by: Jon Paal | last post by:
how does a querystring value get passed to the selectcommand statement of an asp:SqlDataSource? <asp:SqlDataSource id="propertyDataSource" Runat="Server" ConnectionString="<%$...
6
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I'm trying to implement roles in various components (i.e. using different sets of configuration depending, in this case, on which environment your in). Pretty easy to add an AppSettings...
6
by: joehaxor | last post by:
My question is: How do I keep the page from auto querying on page load. I have a ASP:SqlDataSource bound to a Repeater. This repeater replicates tables beneath a search form. The Search form...
1
by: E. Kwong | last post by:
I just want to select records with a certain date field today's date: <asp:SqlDataSource ID="src1" runat="server" ConnectionString="<%$ ConnectionStrings:xyz %>" SelectCommand="SELECT * FROM ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.