473,396 Members | 1,861 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,396 software developers and data experts.

Searching foreign characters - Classic ASP & SQL 2005

I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.

I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. For example, Profiler indicates that a
search for: ×ÓÅ ÏË, ÀÚÁÊ ÎÁ ÚÄÏÒÏ×ØÅ

is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')

How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?

Thanks!
Oct 29 '08 #1
5 2655
Matt wrote:
I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.

I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. For example, Profiler indicates that a
search for: ×ÓÅ ÏË, ÀÚÁÊ ÎÁ ÚÄÏÒÏ×ØÅ

is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')

How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?
How are you passing the data? Oh wait ... "contains" ... this is a
full-text search. I've no experience with those, but I guess I am
wondering if parameters can be used.

Anyways, we need to see the code that receives the strings and
builds/passes them to the sql statement.

--
HTH,
Bob Barrows
Oct 29 '08 #2
hi
how you are making the query?
"Matt" <mj*****@gmail.comescribió en el mensaje
news:d3**********************************@l62g2000 hse.googlegroups.com...
I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.

I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. For example, Profiler indicates that a
search for: ×ÓÅ ÏË, ÀÚÁÊ ÎÁ ÚÄÏÒÏ×ØÅ

is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')

How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?

Thanks!
---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 081029-0, 29/10/2008
Tested on: 30/10/2008 11:04:12 a.m.
avast! - copyright (c) 1988-2008 ALWIL Software.
http://www.avast.com

---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 081029-0, 29/10/2008
Tested on: 30/10/2008 11:06:08 a.m.
avast! - copyright (c) 1988-2008 ALWIL Software.
http://www.avast.com

Oct 30 '08 #3
On Oct 29, 10:29*am, "Bob Barrows" <reb01...@NOyahoo.SPAMcomwrote:
Matt wrote:
I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.
I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. *For example, Profiler indicates that a
search for: ×ÓÅ ÏË, ÀÚÁÊ ÎÁ ÚÄÏÒÏ×ØÅ
is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')
How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?

How are you passing the data? Oh wait ... "contains" ... this is a
full-text search. I've no experience with those, but I guess I am
wondering if parameters can be used.

Anyways, we need to see the code that receives the strings and
builds/passes them to the sql statement.

--
HTH,
Bob Barrows
Thanks to you both for replying!

Here's the code that accepts user input:
<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="40"></td>
</tr>

And here's the code that receives the string and creates the sql
statement (on a separate page from code above):
strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT top 1 '1' " & _
"FROM mydb.dbo.mytable "
'use full-text indexing
strSQL = strSQL & "WHERE contains(myfield, '" & chr(34) &
strMySearch & chr(34) & "') " & _
"OR (myfield2 = '" & strMySearch & "' OR myfield3= '" &
strMySearch & "') "

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
strExists = true
end if

FWIW, I'm also encountering this problem when not using full-text
indexes - here's an example:

<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="50"></td>
</tr>

strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT distinct myfield " & _
"FROM mydb.dbo.mytable " & _
"WHERE 1=1 "
If Len(strMySearch) 0 Then
strSQL = strSQL & "AND myfield like '%" & UCASE(strMySearch) & "%'
"
End If

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
arrMySearch = objRS.GetRows()
strUbound = UBound(arrMySearch,2)
end if
Nov 3 '08 #4
"Matt" <mj*****@gmail.comwrote in message
news:13**********************************@z6g2000p re.googlegroups.com...
On Oct 29, 10:29 am, "Bob Barrows" <reb01...@NOyahoo.SPAMcomwrote:
Matt wrote:
I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.
I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. For example, Profiler indicates that a
search for: ×ÓÅ ÏË, ÀÚÁÊ ÎÁ ÚÄÏÒÏ×ØÅ
is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')
How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?

How are you passing the data? Oh wait ... "contains" ... this is a
full-text search. I've no experience with those, but I guess I am
wondering if parameters can be used.

Anyways, we need to see the code that receives the strings and
builds/passes them to the sql statement.

--
HTH,
Bob Barrows
>>>>>>>>>>>>>>>>>>>
Thanks to you both for replying!

Here's the code that accepts user input:
<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="40"></td>
</tr>

And here's the code that receives the string and creates the sql
statement (on a separate page from code above):
strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT top 1 '1' " & _
"FROM mydb.dbo.mytable "
'use full-text indexing
strSQL = strSQL & "WHERE contains(myfield, '" & chr(34) &
strMySearch & chr(34) & "') " & _
"OR (myfield2 = '" & strMySearch & "' OR myfield3= '" &
strMySearch & "') "

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
strExists = true
end if

FWIW, I'm also encountering this problem when not using full-text
indexes - here's an example:

<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="50"></td>
</tr>

strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT distinct myfield " & _
"FROM mydb.dbo.mytable " & _
"WHERE 1=1 "
If Len(strMySearch) 0 Then
strSQL = strSQL & "AND myfield like '%" & UCASE(strMySearch) & "%'
"
End If

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
arrMySearch = objRS.GetRows()
strUbound = UBound(arrMySearch,2)
end if
>>>>>>>>>>>>>>>>>>>>

I'm not convinced this is a SQL issue at all, not to say there isn't one, we
first need to discover how we are seeing &#xxxx; entities, this is
definitely not being done by SQL.

How are you acquiring the text of the SQL executed, (please be a specific as
possible describing your process of discovering the text, in these cases the
devil is in the detail)?

Is this a METHOD="POST or a METHOD="GET" form?
Is the form action URL the same page that holds for form or different one?
Are you intiailising the value of the input when generating the HTML form?
What codepage is set for the form page and the receiving page?
What charset is specified on the response for the form page?

BTW, You should google up SQL Injection Attack, the technique of
concatenating into SQL code value posted from a client leaves your site
vunerable.

--
Anthony Jones - MVP ASP/ASP.NET

Nov 4 '08 #5
On Nov 4, 4:20*am, "Anthony Jones" <AnthonyWJo...@yadayadayada.com>
wrote:
"Matt" <mjhs...@gmail.comwrote in message

news:13**********************************@z6g2000p re.googlegroups.com...
On Oct 29, 10:29 am, "Bob Barrows" <reb01...@NOyahoo.SPAMcomwrote:
Matt wrote:
I originally posted this in microsoft.public.sqlserver.server, and it
was suggested that I post here.
I'm having problems with searches via a classic ASP front-end of terms
including foreign characters. For example, Profiler indicates that a
search for: ,
is actually executed as:
SELECT top 1 '1' from dbo.mytable where contains(myfield,
'"все ок, юзай
на
здоровье"')
How do I prevent the foreign characters (in this case Cyrillic) from
being converted to HTML ASCII?
How are you passing the data? Oh wait ... "contains" ... this is a
full-text search. I've no experience with those, but I guess I am
wondering if parameters can be used.
Anyways, we need to see the code that receives the strings and
builds/passes them to the sql statement.
--
HTH,
Bob Barrows

Thanks to you both for replying!

Here's the code that accepts user input:
<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="40"></td>
</tr>

And here's the code that receives the string and creates the sql
statement (on a separate page from code above):
strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT top 1 '1' " & _
"FROM mydb.dbo.mytable "
'use full-text indexing
strSQL = strSQL & "WHERE contains(myfield, '" & chr(34) &
strMySearch & chr(34) & "') " & _
* *"OR (myfield2 = '" & strMySearch & "' OR myfield3= '" &
strMySearch & "') "

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
strExists = true
end if

FWIW, I'm also encountering this problem when not using full-text
indexes - here's an example:

<tr>
<td><b>My Search</b></td>
<td><input type="text" name="strMySearch" size="50"></td>
</tr>

strMySearch = Trim(Request("strMySearch"))

strSQL = "SELECT distinct myfield " & _
"FROM mydb.dbo.mytable " & _
"WHERE 1=1 "
If Len(strMySearch) 0 Then
strSQL = strSQL & "AND myfield like '%" & UCASE(strMySearch) & "%'
"
End If

set objRS = objConn.execute(strSQL)
if not objRS.EOF then
arrMySearch = objRS.GetRows()
strUbound = UBound(arrMySearch,2)
end if

I'm not convinced this is a SQL issue at all, not to say there isn't one,we
first need to discover how we are seeing &#xxxx; entities, this is
definitely not being done by SQL.

How are you acquiring the text of the SQL executed, (please be a specificas
possible describing your process of discovering the text, in these cases the
devil is in the detail)?

Is this a METHOD="POST or a METHOD="GET" form?
Is the form action URL the same page that holds for form or different one?
Are you intiailising the value of the input when generating the HTML form?
What codepage is set for the form page and the receiving page?
What charset is specified on the response for the form page?

BTW, You should google up SQL Injection Attack, the technique of
concatenating into SQL code value posted from a client leaves your site
vunerable.

--
Anthony Jones - MVP ASP/ASP.NET
Thanks for the response, Anthony. You pointed me in the right
direction and I was able to solve the problem by setting the codepage
on both the input and output forms to 65001 and the character set to
utf-8. Also, thanks for the warning about SQL injection. While this
is an internal site with trusted users, I would agree we should fix
this vulnerability ASAP.

Thanks again!
Nov 13 '08 #6

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

Similar topics

4
by: Toffe | last post by:
Hi, I've got a problem with regular expressions and strings containing Swedish characters (åäö). I basically have a PHP script that highlights certain words in a text. I found the code...
3
by: Tetsuo | last post by:
How do I get Python to work with foreign characters? When I try to print them, I get a unicode error (characters not ASCII). Wasn't unicode invented for the express purpose of working with...
31
by: Robert Brown | last post by:
Let's say I have a type hierarchy: (just an example) the general entity customer: CREATE TABLE customer(customer_id int, customer_name varchar(250), customer_type int) three specific...
8
by: Mike | last post by:
Hi, I am using Python to scrape web pages and I do not have problem unless I run into a site that is utf-8. It seems & is changed to &amp; when the site is utf-8. If I try to replace it with...
23
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite,...
1
by: Ole | last post by:
Goodday group, how do i make it possible that, given the fact that all required language packs are installed, a website can present any kind of language. I want to build a knowledge management...
0
by: tatemononai | last post by:
I have an asp.net application that mixes English and Japanese. I can put Japanese and English characters directly on an .aspx page and it works without any problem at all. However, when I try to...
2
by: tatemononai | last post by:
I'm trying to display Japanese characters on an asp.net web forms application. I am about ready to shave my head too. The whole thing is just silly. Ok, inside Visual Studio I can enter...
3
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I get an error on a .net 2.0 page when I use foreign characters, such as ç or ã. Setting validateRequest=false handles this, but is there a way to keep validateRequest=true but allow foreign...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.