Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read UNICODE Character in Visual Basic from SQL Database

Status
Not open for further replies.

mtcg

Programmer
Dec 13, 2004
2
PS
Dear Friends,
This is the first time I write here, but I need a very urgent help from you, to inform me how to solve this problem : How to read UNICODE Characters (UTF-8) from SQL database into Text Field in Visual Basic.

I need this so urgent plzzzzzzzzzzzzzz.

 
Use getchunk to build the string from your field. Then use strconv(yourstring, vbFromUnicode) to convert the string from unicode to ASCII.

That should help...it's a while since I did any Unicode stuff but this is how I seem to remember it...
 
You shouldn't have any problems, as VB string variables are Unicode aware (UTF-16, actually). Most databases (Oracle, MS SQLServer) store them as UTF-16 as well. ADO is also Unicode aware (technically, VB and ADO use COM BSTR objects to pass strings around, and they know Unicode).

What *may* be throwing you off is if you are using the VB command window to inspect the variable's contents. The command window only uses an ANSI font, so any hi-bit characters will show up as garbage. But they're still OK in memory.

I would suggest you write a helper function that takes a string and writes it out to a text file. If you use the FileScriptingObject, be sure to set the Unicode flag, but the Win32 CreateFile api is probably better. You can call this function from your command window, passing the string. You won't have any problems viewing the file with Notepad, as it has full Unicode support.

Also -
If you're using ADO parameters to pass your Unicode data to your database, be sure and use the "W" version of the datatype constants:
[tab]adVarWChar
[tab]adWChar
[tab]adWText

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks for Vbrit & Chip H, I will do my tests and come back to you asap.

Rassem
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top