Wednesday, March 21, 2012

problem with >>insert into varchar field shows "?"

i would like to insert thai characters into varchar field in Database. and show that to a label.

now the problem is when i insert into database it becomes "?"

and when i display to Lable also "?".

is there anyway to fix this?

input comes from Textbox(vb.net)

output to Label.

thanks.

thompson.

You need to specifically 'tell' SQL Server that the incoming data is UNICODE. The common method to do that is to preface the data with the letter [ N ].

It would be done something like this:

INSERT INTO MyTable ( MyColumn ) VALUES ( N'MyUnicodeValue' )

|||

Including Arnie Rowland's suggestion, check the datatype of your table column. It shoule be NVarchar. Varchar only supports ASCII chars, if you want to insert Unicode values then it should be NVarchar/NChar/NText datatype.

Note: Varchar is not equal to NVarchar

|||thanks to everyone answer this post. the problem has been solved.

No comments:

Post a Comment