﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-mycpp</title><link>http://www.cppblog.com/xhubobo/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 05 Apr 2026 18:22:00 GMT</lastBuildDate><pubDate>Sun, 05 Apr 2026 18:22:00 GMT</pubDate><ttl>60</ttl><item><title>File: winocc.cpp Line: 279错误</title><link>http://www.cppblog.com/xhubobo/archive/2012/06/29/180771.html</link><dc:creator>xhubobo</dc:creator><author>xhubobo</author><pubDate>Fri, 29 Jun 2012 07:51:00 GMT</pubDate><guid>http://www.cppblog.com/xhubobo/archive/2012/06/29/180771.html</guid><wfw:comment>http://www.cppblog.com/xhubobo/comments/180771.html</wfw:comment><comments>http://www.cppblog.com/xhubobo/archive/2012/06/29/180771.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xhubobo/comments/commentRss/180771.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xhubobo/services/trackbacks/180771.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;查程序在运行的时候报错：&#8220;Debug Assertion Failed! File: winocc.cpp Line: 279&#8221;错误，但是忽略之后一切正常。<br />这种错误一般是在对话框OnSize函数中，对控件重新布局时使用MoveWindow函数时引起的。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这是因为程序在执行OnSize函数的时候，相关控件还没有生成，所以其成员m_hWnd是NULL，当然在执行MoveWindow<br />的时候就会出现断言错误：ASSERT(::IsWindow(m_hWnd));</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;解决方法是，在控件进行MoveWindow时先判断一下是否存在：</p>
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><img src="http://www.cppblog.com/images/OutliningIndicators/None.gif" align="top"  alt="" /><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">if</span><span style="color: #000000">&nbsp;(m_ctrl.m_hWnd)<br /><img id="Codehighlighter1_21_53_Open_Image" onclick="this.style.display='none'; Codehighlighter1_21_53_Open_Text.style.display='none'; Codehighlighter1_21_53_Closed_Image.style.display='inline'; Codehighlighter1_21_53_Closed_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockStart.gif" align="top"><img id="Codehighlighter1_21_53_Closed_Image" style="display: none" onclick="this.style.display='none'; Codehighlighter1_21_53_Closed_Text.style.display='none'; Codehighlighter1_21_53_Open_Image.style.display='inline'; Codehighlighter1_21_53_Open_Text.style.display='inline';" src="http://www.cppblog.com/images/OutliningIndicators/ContractedBlock.gif" align="top">&nbsp;</span><span id="Codehighlighter1_21_53_Closed_Text" style="border-right: #808080 1px solid; border-top: #808080 1px solid; display: none; border-left: #808080 1px solid; border-bottom: #808080 1px solid; background-color: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"  alt="" /></span><span id="Codehighlighter1_21_53_Open_Text"><span style="color: #000000">{<br /><img src="http://www.cppblog.com/images/OutliningIndicators/InBlock.gif" align="top"  alt="" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_ctrl.MoveWindow(rc);<br /><img src="http://www.cppblog.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top"  alt="" />&nbsp;}</span></span></div>
<p><br />&nbsp;</p>  <img src ="http://www.cppblog.com/xhubobo/aggbug/180771.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xhubobo/" target="_blank">xhubobo</a> 2012-06-29 15:51 <a href="http://www.cppblog.com/xhubobo/archive/2012/06/29/180771.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>无效的字段名或字段索引</title><link>http://www.cppblog.com/xhubobo/archive/2012/06/29/180770.html</link><dc:creator>xhubobo</dc:creator><author>xhubobo</author><pubDate>Fri, 29 Jun 2012 07:48:00 GMT</pubDate><guid>http://www.cppblog.com/xhubobo/archive/2012/06/29/180770.html</guid><wfw:comment>http://www.cppblog.com/xhubobo/comments/180770.html</wfw:comment><comments>http://www.cppblog.com/xhubobo/archive/2012/06/29/180770.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xhubobo/comments/commentRss/180770.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xhubobo/services/trackbacks/180770.html</trackback:ping><description><![CDATA[<div class="content" id="content_c065d4beae26492a18d81f62">
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在使用MFC的CRecord类及其派生类的时候，如果需要获取某个字段的值，就需要用到GetFieldValue的方法了。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;据我所知，GetFieldValue方法有2个重载版本，一个是GetFieldValue（"字段索引","变量名"），另一个是GetFieldValue（"字段名","变量名"）。如果需要获取多个字段的值，那么这两种方法都对获取字段值的顺序没有要求。需要注意的是，在使用字段索引的方法时，用SELECT语句查询出来的字段的索引时从0开始的，由于GetFieldValue方法中索引的类型是short，因此需要用(short)0将0强制转换为short类型，否则会出现&#8220;error C2668: 'GetFieldValue' : ambiguous call to overloaded function&#8221;的错误，这在另外一篇文章里面有所描述。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;最后，进入本文章的主要内容。在使用GetFieldValue方法的时候，如果使用字段名获取字段值，尽管对顺序没有特殊要求，但是很多时候在运行程序时会出现&#8220;无效的字段名或字段索引&#8221;的错误，这是因为该方法对变量名的大小写有要求，将字段名修改为大写形式，即可解决问题，例如GetFieldValue( "Rid" , val)会出错，而对于GetFieldValue( "RID" , val)，不管数据表中的字段名是否大小写都能顺利通过。</p></div><img src ="http://www.cppblog.com/xhubobo/aggbug/180770.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xhubobo/" target="_blank">xhubobo</a> 2012-06-29 15:48 <a href="http://www.cppblog.com/xhubobo/archive/2012/06/29/180770.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用CRecordset::GetFieldValue的错误:error C2668</title><link>http://www.cppblog.com/xhubobo/archive/2012/06/29/180769.html</link><dc:creator>xhubobo</dc:creator><author>xhubobo</author><pubDate>Fri, 29 Jun 2012 07:47:00 GMT</pubDate><guid>http://www.cppblog.com/xhubobo/archive/2012/06/29/180769.html</guid><wfw:comment>http://www.cppblog.com/xhubobo/comments/180769.html</wfw:comment><comments>http://www.cppblog.com/xhubobo/archive/2012/06/29/180769.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/xhubobo/comments/commentRss/180769.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/xhubobo/services/trackbacks/180769.html</trackback:ping><description><![CDATA[<div class="content" id="content_bc09418323256f820cf4d295">
<p>&nbsp;</p>
<div>
<p>m_rsSet.GetFieldValue( 0 , val);</p>
<p>编译时出现：error C2668: 'GetFieldValue' : ambiguous call to overloaded function</p>
<p>应改为：m_rsSet.GetFieldValue( (short)0 , val);</p>
<p>原因：GetFieldValue函数的第一个参数是short类型。</p></div></div> <img src ="http://www.cppblog.com/xhubobo/aggbug/180769.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/xhubobo/" target="_blank">xhubobo</a> 2012-06-29 15:47 <a href="http://www.cppblog.com/xhubobo/archive/2012/06/29/180769.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>