473,545 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with asp:SqlDataSour ce 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:SqlDataSour ce 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:SqlDataSou rce SelectCommand=" SELECT * FROM [tblCards] WHERE
([Titre] LIKE '%' + @Search + '%')>
<SelectParamete rs>
<asp:ControlPar ameter ControlID="txtS earch" Name="Search"
PropertyName="T ext" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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 5176
al*********@gma il.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:SqlDataSour ce 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:SqlDataSou rce SelectCommand=" SELECT * FROM [tblCards] WHERE
([Titre] LIKE '%' + @Search + '%')>
<SelectParamete rs>
<asp:ControlPar ameter ControlID="txtS earch" Name="Search"
PropertyName="T ext" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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
5020
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 select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for...
0
2613
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é, Sauté, etc...) and I try to do this: <asp:SqlDataSource SelectCommand="SELECT * FROM WHERE Title LIKE '%' + @Search + '%') > <SelectParameters>...
1
1317
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
4839
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 only examples i have seen use hard-coded references to connection strings defined in machine.config, e.g. <asp:SqlDataSource ID="SqlDataSource2"...
4
1491
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 asp:GridView (me.GridView1.something) instead I have to create a new sqlcon,selectcommand,dataset,dataadapter.... Is there no easier way?
1
1258
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="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="SELECT * FROM WHERE propertyid = @id " />
6
6452
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 variable in most cases. The thing that's causing me difficulty are the asp:SqlDataSource components in an aspx page. Depending on the role setting,...
6
2209
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 is a postback. I want to page to load with no search results until they actively enter data into the search form and click the search button. There...
1
1795
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 WHERE ? " OnSelected="src1_Selected"> <SelectParameters>
0
7668
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5984
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3466
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1025
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.