VS2010 +mysql API查询数据库乱码,该如何解决

VS2010 +mysql API查询数据库乱码
Win7 64bit + VS2010
CentOS6.5 64bit + mysql 5.1.37 64bit

数据库编码都是gb2312,但是用VS通过API连接mysql,查询得到的结果都是乱码。
如果是中文乱码的话,应该就是编码的问题了,但是,查询一个整形字段,得到的结果都是乱码,这就不知道是什么原因了。



mysql_init(&m_mysql);
mysql_options(&m_mysql,MYSQL_SET_CHARSET_NAME,"gb2312");
if(!mysql_real_connect(&m_mysql,"localhost","username","passowrd","database",3306,NULL,0))
{
AfxMessageBox(_T("连接mysql失败!"));
return FALSE;
}
else
{
char * sqlStr;
// sqlStr="select a.orderNum,companyName,corporate,scale,trade,area,address,authorization,linkman,phone,email,website,orderDate from tb_appApply a left join tb_handle h on(a.orderNum=h.orderNum) where(h.wasRelease='' or h.wasRelease is null);";
sqlStr="select orderNum from tb_handle;";

if(mysql_real_query(&m_mysql,sqlStr,(UINT)strlen(sqlStr))!=0)
{
AfxMessageBox(_T("读取数据表失败!"));
return FALSE;
}
if(!(m_pResult=mysql_use_result(&m_mysql)))
{
AfxMessageBox(_T("读取数据集失败!"));
return FALSE;
}
CString str;
int i=0;
while(m_row=mysql_fetch_row(m_pResult))
{
str.Format(_T("%d"),i+1);
m_applyList.InsertItem(i,str);
for(int j=0;j<14;j++)
{
str.Format(_T("%s"),m_row[j]);
m_applyList.SetItemText(i,j+1,str);  //把数据导入ListControl列表控件
}
i++;
// GetDlgItem(IDC_STATIC1)->SetWindowTextW(LPCTSTR(m_row[1]));
}
}

------解决方案--------------------
估计数据库查询到的是ANSI编码的字符串,而工程是Unicode的
转换一下吧 参考 MultiByteToWideChar