Get Unicode Text From Access DB in VB

Posted on 2004-11-14
Last Modified: 2012-05-05

I'm using a database I created in MS Access XP. From a VB 6.0 application I connect to my databse using
MS Jet 4.0 engine. My database contains tables with text fields that contain unicode characters.
When I try to get these records from the database all the unicode characters are replaced with '?'s

I already checked the controls in VB and they can display unicode characters. The problem is that I get
the text from the database already messed up.

Who can I get this text right? Do I need to change the engine I use to connect to the database?
Do I need to configure the fields in my DB differently?

Tanks in advance,
Nisim Aytek.
Question by:aytek_nisi

    Expert Comment

    This is a test comment
    LVL 58

    Accepted Solution

    First, we should make sure whether you get unicode from Access or not.
    Using a DAO or ADODB recordset, retrieve a string for which you know there is an extenden character at position n. Extract that to a string variable. Example:

        Dim strTest as String
        strTest = Mid(recTable.Fields(2).Value, 5)

    This would store a string starting with the fifth character of the third field into the variable. I can guarantee that the Field object does return a unicode enabled string (i.e. an array of integers, not bytes). Now observe this in the immediate pane:

        ? AscW(strTest)

    If you get 63, this is no longer Unicode. If it is higher than 255, the problem is not with the JetEngine or the database. If you *do* get 63, it might be worthwile to write unicode into the table, for example ChrW(916) should be the greek upper-case delta (a triangle). Write that into a field, and read it back. If you can do that, it means that the data was flattened to 8-bit before entering the table...

    As for enabling Unicode data in a VB control, you should ask in the VB channel. The only advice here would be to build a unicode string (using ChrW(913) & ChrW(914) & ... for a greek alphabet) and to assign that to an unbound control. If that shows, Unicode can be displayed.

    Good Luck!

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now