关于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.
本文探讨了MFCDAO编程中使用CDaoRecordset::SetFieldValue()方法遇到的问题,当使用COleVariant传递字符串时,只有第一个字符被正确复制到数据库中。文章提供了修复该问题的方法,并引用了MSDN中关于此bug的相关文章。

386

被折叠的 条评论
为什么被折叠?



