473,406 Members | 2,707 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,406 software developers and data experts.

What is correct syntax for SQL SELECT statement to read Unicode?

We need to read a SQL database containing a mix of English words and Chinese
Characters. We think we need to use the N'xxxx' to read the Unicode.

We have one place where the SELECT statement works fine. Here is that
statement:
dim objCmdCategories as new SQLDataAdapter ("select distinct
N'product_category' from " & _
"tblproducts where product_status=1 order by product_category", objConn)

However, we can't seem to get another SELECT statement to work. Here is the
2nd SELECT statuement:
myCommand = new SQLCommand("SELECT product_id, N'product_category',
product_name, product_weight, product_featured, product_status FROM
tblProducts ", myConnection)

This works fine if we take out the N'xxxx' . But if we leave it in, we get
the following .Net error:

A field or property with the name 'product_category' was not found on the
selected datasource.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: A field or property with the
name 'product_category' was not found on the selected datasource.

Source Error:
Line 15: myConnection.Open()
Line 16: dgProducts.DataSource = myCommand.ExecuteReader()
Line 17: dgProducts.DataBind() <=== This is highlighted Red
Line 18: myConnection.Close()
Line 19: end sub

Question: How to read the Unicode field in this SELECT statement?

--
John
Jul 21 '05 #1
1 11306
You are partly wrong. The N'xxxx' syntax is only for string constants
inside Stored Procedures and Function on SQL-Server. (I don't know if you
can use the N'xxxx' syntax for the *Name* of the column if it is itself
Unicode).

For reading Unicode, the fields must be of type nchar, nvarchar or ntext
instead of char, varchar or text. This is for Unicode 16, taking into
account that if it is UTF8, the client will properly decode it and translate
it to UTF16 before sending it to the SQL-Server. Other fields, like binary,
varbinary and image, can also be used for storing UTF8 but you will lose
some capabilities, like Sorting.

For more information:
http://msdn.microsoft.com/library/de...taencoding.asp
--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
"John Hall" <Jo******@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
We need to read a SQL database containing a mix of English words and
Chinese
Characters. We think we need to use the N'xxxx' to read the Unicode.

We have one place where the SELECT statement works fine. Here is that
statement:
dim objCmdCategories as new SQLDataAdapter ("select distinct
N'product_category' from " & _
"tblproducts where product_status=1 order by product_category", objConn)

However, we can't seem to get another SELECT statement to work. Here is
the
2nd SELECT statuement:
myCommand = new SQLCommand("SELECT product_id, N'product_category',
product_name, product_weight, product_featured, product_status FROM
tblProducts ", myConnection)

This works fine if we take out the N'xxxx' . But if we leave it in, we get
the following .Net error:

A field or property with the name 'product_category' was not found on the
selected datasource.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: A field or property with the
name 'product_category' was not found on the selected datasource.

Source Error:
Line 15: myConnection.Open()
Line 16: dgProducts.DataSource = myCommand.ExecuteReader()
Line 17: dgProducts.DataBind() <=== This is highlighted Red
Line 18: myConnection.Close()
Line 19: end sub

Question: How to read the Unicode field in this SELECT statement?

--
John

Jul 21 '05 #2

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

Similar topics

14
by: bolidev | last post by:
I'm new to SQL and can't figure out how to update my table (StoreItemStatus) that contains the current status for items in each store (STORE_KEY, ITEM_KEY, STATUS,...). I get updated status info...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
1
by: John Hall | last post by:
We need to read a SQL database containing a mix of English words and Chinese Characters. We think we need to use the N'xxxx' to read the Unicode. We have one place where the SELECT statement...
9
by: mistral | last post by:
What is difference between two encoding methods below and what method can be considered more "web safe", fully retaining functionality of the original source code, without the danger of...
4
MMcCarthy
by: MMcCarthy | last post by:
To view Access queries in SQL rather than Access query design - open the query design window and change the view to SQL: Select Statement SELECT FROM ; Append Statement INSERT INTO (, , )...
23
by: Jess | last post by:
Hello, I understand the default-initialization happens if we don't initialize an object explicitly. I think for an object of a class type, the value is determined by the constructor, and for...
11
by: James R. Davis | last post by:
Yes, a newbie here. Though I am making progress, slowly, I am also getting more and more confused. With ASP, when I wanted to do something as trivial as updating a visitor counter, I...
6
Soniad
by: Soniad | last post by:
Hello, I am excecuting a stored procedure in my ASP page , it has one out parameter (@confirm) . after executing the procedure i want to retreive this out parameter and assign it to variable...
0
by: Zettai | last post by:
Hi All, I am trying to query a mysql database using the 'LIKE' keyword within my query based on what the user has input. It works if I pass the string, however I am having trouble getting it to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.