目前在学用OLE进行数据库编程,遇到以下不懂的问题:
我在新建project过程中,在datasource中选定一ACCESS数据库MYDB.mdb,然后选其中一emp表并测试连接成功,
emp定义如下:字段名称    id name   eno   dno  
             数据类型    自动编号  文本      数字    数字
             字段大小    长整型 50        长整型  长整型vc建立project(名字为Access)中在CAccessSet.h中有如下类定义:
class CEMP
{
public:
CEMP()
{
memset( (void*)this, 0, sizeof(*this) );
}; int m_DNO;
int m_ENO;
int m_ID;
wchar_t m_NAME[26];
BEGIN_COLUMN_MAP(CEMP)
COLUMN_ENTRY_TYPE(4, DBTYPE_I4, m_DNO)
COLUMN_ENTRY_TYPE(3, DBTYPE_I4, m_ENO)
COLUMN_ENTRY_TYPE(1, DBTYPE_I4, m_ID)
COLUMN_ENTRY_TYPE(2, DBTYPE_WSTR, m_NAME)
END_COLUMN_MAP()};然后我在ResourceView中的Dialog文件夹下的IDD_ACCESS_FORM中添加3个文本控件IDC_DNO,IDC_ENO,
IDC_NAME,然后添加如下代码:void CAccessView::DoDataExchange(CDataExchange* pDX)
{
COleDBRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAccessView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP DDX_Text(pDX,IDC_ENO,m_pSet->m_ENO);
DDX_Text(pDX,IDC_DNO,m_pSet->m_DNO);
// DDX_Text(pDX,IDC_NAME,m_pSet->m_NAME);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        编译后此语句报错error C2665: 'DDX_Text' : none of the 12 overloads can convert parameter 3 from type 'unsigned short [26]'
                                            Error executing cl.exe.
}请问是为什么?wchar_t是什么类型?
msdn中说是internal type of a wide character,Useful for writing portable programs for
international ets.  (英文有点菜菜,不太懂)希望了解的高手指点一下吧,谢谢啦!

解决方案 »

  1.   

    The TCHAR data type is a Win32 character string that can be used to describe ANSI, DBCS, or Unicode strings. For ANSI and DBCS platforms, TCHAR is defined as follows:typedef char          TCHAR;  
      
    For Unicode platforms, TCHAR is defined as synonymous with the WCHAR type也就是说这个是为了UNICODE存在的
      

  2.   

    please try following:#ifdef UNICODE
    wchar_t m_NAME[26];
    else
    char m_NAME[26];
    #endif
      

  3.   

    那我要怎么用DDX_TEXT对这样的类型进行数据交换呢?