We help IT Professionals succeed at work.

Reading Unicode text from an Access 2000 database

Dranoel
Dranoel asked
on
I have an application that merges a Unicode text file with an Access 2000 database, creating a Unicode text file.  My Access database (and my Unicode text files) contain Chinese characters.

My problem is in getting the data out of my database directly into my VB application without losing the Chinese.  I can read the rows/fields from the database, but all of my Chinese characters are converted to '?'.

However, I do import the database into my VB application into a DataGrid and the Chinese characters are displayed.  So far my attempt to get data either from the DataGrid or from the database using ADODB.Recordset have resulted in the translation to question marks.
Comment
Watch Question

Try using the StrConv function.

Author

Commented:
Thanks, but I had tried that before I determined that the data is already converted before it can be handed off to StrConv. One gets two-byte characters but the Chinese is already lost.

Author

Commented:
By the way, I have worked out a "work-around" but the solution to this would take two manual steps out of my process.
You have tried StrConv("string", vbUnicode)?  That always works for me for unicode strings (the ones with all the question marks in it)

Author

Commented:
Yes I have.  Something like "newString = StrConv(rs.field(1))" (did not look up syntax).  I tried several different ways, including getting the data from a datagrid.  All executed but it appears the data from the databse has already lost its unicode property when it enters VB.
However, I can read from a unicode text file and keep the unicode.

Can you look up the line of code you tried and post it?

Author

Commented:
Tomorrow late, I will post an example.  I have meetings in the morning.
You know, if I read a Unicode Text file into a string using TextStream, no conversion is necessary to preserve the Unicode of the input.  Hence, if I can get Unicode in from the recordset or the datagrid, I am home free.  I do not see how StrConv can help, and I have tried already anyway, but I'm game. Is it not true that the input is done and the Unicode values are lost before it can be operated on by StrConv?

I (obviously) cannot be sure, but I have had this problem many times (the input that looks like '????? ??? ??') and have always been able to use strConv to make into unicode.  That's why I want to see a code sample.

Author

Commented:
My apology for having said StrConv did not work.  Apparently when I tried it, I had something else incorrect. My snippet to demonstrate what did and did not work showed it worked!  Thanks.  Problem solved.

Author

Commented:
Thanks for sticking with me.
Thanks for being patient and trying it even though you thought I was wrong.

:-)  

Explore More ContentExplore courses, solutions, and other research materials related to this topic.