Microsoft KB Archive/173423: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - "<" to "<")
 
Line 64: Line 64:
<pre class="codesample">  BOOL CYourRecordset::IsAnyFieldNull()
<pre class="codesample">  BOOL CYourRecordset::IsAnyFieldNull()
   {
   {
       for (DWORD nIndex = 0; nIndex&lt;=m_nFields-1; nIndex++)
       for (DWORD nIndex = 0; nIndex<=m_nFields-1; nIndex++)
       {
       {
         if (IsFieldStatusNull(nIndex))
         if (IsFieldStatusNull(nIndex))

Latest revision as of 16:23, 20 July 2020

Knowledge Base


DOC: IsFieldNull() Does Not Accept NULL

Article ID: 173423

Article Last Modified on 10/17/2003



APPLIES TO

  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition



This article was previously published under Q173423

SUMMARY

The documentation for Visual C++ states the following about the argument for CRecordset::IsFieldNull():

pv A pointer to the field data member whose status you want to check, or NULL to determine if any of the fields are Null.


According to the documentation, you should be able to pass in NULL to determine if any of the fields are null.

Beginning with Visual C++ version 4.2, this is not correct. Passing a value of NULL will cause an exception to be thrown.

MORE INFORMATION

You can write a function to check whether any fields are null. Here is what the function would look like:

   BOOL CYourRecordset::IsAnyFieldNull()
   {
      for (DWORD nIndex = 0; nIndex<=m_nFields-1; nIndex++)
      {
        if (IsFieldStatusNull(nIndex))
             return TRUE;
      }
      return FALSE;
   }
                

Notice that the IsAnyFieldNull() function uses an undocumented function IsFieldStatusNull(). This function is in the implementation section of the CRecordset class so note that the function may change in future releases of MFC. To write code that is not dependent upon undocumented functions, call IsFieldNull() for each field member in the recordset instead.


Additional query words: kbDatabase kbMFC kbODBC kbOLDocs kbVC420 kbVC500 kbDSupport kbdse

Keywords: kbbug kbdocerr KB173423