关于MFC DAO中 CDaoRecordset::SetFieldValue()
在下边的代码中,
rs3.AddNew();
intGotten = 0;
for (intGotten=0;intGotten<=4;intGotten++)
{
strTemp = gotten[intGotten];
// tmpVal = COleVariant(strTemp);
// rs3.SetFieldValue(intGotten,tmpVal);
// // 上边的两行被下边的两行替换,上边的两行不能正常实现目的,只显示数据的第一个字符.?
tmpStr = LPCTSTR (strTemp);
rs3.SetFieldValue(intGotten,tmpStr);
}
rs3.Update();
被注释的两行代码为什么不行呢?不解.
这里的数据类型转换有什么问题呢?
在msdn上发现一篇文章,却原来是一个bug.题目是
PRB: MFC DAO Functions Accepting COleVariant Strings May Fail
地址 http://support.microsoft.com/kb/140599/en-us
其中有一段,
This code causes only the first letters of each string to be copied to the database with a non-UNICODE build. In this case, the letter M will be copied to both fields.