Displaying unicode text from access 2002 database in VC++6 control

  • Thread starter Thread starter Sir
  • Start date Start date
S

Sir

How to display unicode text from access 2002 database in VC++6 controls?
For example, in CListBox, CListCtrl and others. Supporting languages from
right to left in control panel ... languages... installed.
I have defined _UNICODE in the project->settings->c/c++ tab under
preprocessor definitions and write wWinMainCRTStartup in the
project->settings->Link under Entry-point symbol in category output, then
removed the _MBCS definition in the project->settings->c/c++ tab under
preprocessor definitions.
 
How to display unicode text from access 2002 database in VC++6 controls?
For example, in CListBox, CListCtrl and others. Supporting languages from
right to left in control panel ... languages... installed.
I have defined _UNICODE

You'll probably also need to #define UNICODE as well as _UNICODE.

Once you've got a fully Unicode application, the only other factor is
how you're accessing the database.

Dave
 
Thank you.
In SomeDlg.cpp I've written
#define _UNICODE.
But, may be the way, which I use to access *.mdb is not well:

1.
CDatabase m_db;
CString sConn=_T("DBQ=c:\\f\\f\\m.mdb;Driver={Microsoft Access Driver
(*.mdb)};PWD=;UID=;");
m_db.OpenEx(sConn);
CRecordset rs(&m_db);
CString sSQL= "SELECT f1 FROM w ";
rs.Open( CRecordset::dynaset,sSQL);
short iFI=0; //field index
CDBVariant vFV;
//CString* psFV;
CString sFV;
while (!rs.IsEOF())
{
rs.GetFieldValue(iFI,vFV);
//psFV=vFV.m_pstring;
//sFV=*psFV;
sFV=*vFV.m_pstring;
m_list.AddString(sFV);
rs.Move(1);
}
rs.Close();
m_db.Close();
//m_list - member variable of CListBox.

2.Using CListCtrl gives the same result,
the letters with Unicode appear as ??????
(for example, if Unicode eq. 1570), but with
standard english letters everything is normal.

Inside *.mdb, in a table the field type is: text(255).
I'm using VC++6.
 
In SomeDlg.cpp I've written
#define _UNICODE.

As I mentioned, you should probably also define UNICODE as well as
_UNICODE - and I'd recommend you do it in your project's preprocessor
settings so that all modules inherit it.
But, may be the way, which I use to access *.mdb is not well:

I'm afraid I know next to nothing about database access. However...
sFV=*vFV.m_pstring;

If you change that line to use the explicit wide string - m_pstringW,
does your code compile cleanly? If it doesn't, you've still not got a
fully Unicode application.

Dave
 
For a well-written Unicode application, the system-locale setting should be
irrelevant-test to verify this is the case.
 
Back
Top