Friday, February 24, 2012

Display Results Based on Query

Hi,

I don't know if anyone has encountered this before but here goes:

I've a select clause below:
result = "Select * from person where LocalName LIKE N'" + queryLocalName + "'"

queryLocalName is an input field that allows the user to search for non-English characters in the database.

What I'm wondering is what kind of effect is the N in the where clause is having?

I can't seem to get it to work when doing it via the web. I've tested in the database itself, got it to work using the SQL Analyser but when testing on the web, it can't find because ? are appearing in the result.The 'N' in your query tells SQL Server that the bit in quotes is Unicode. That means that the data in queryLocalName has to be either ANSI for regular Latin text or Unicode for other languages. My guess is that queryLocalName is not in Unicode. From what I remember of this a year or so ago when I was involved in 'languagizing' a site it depends on the encoding of the .asp files (seriously) and the content-type meta tag in your page.

What I would do is to print out the character values of queryLocalName to verify they are Unicode -- you could enter the same text into your database via Query Analyser and print them side by side.

You SQL is correct, the data you are passing is not.|||Thanks for the explanation. I'll check that the data is in Unicode. :)

No comments:

Post a Comment