INF: Common SQL-DMO C/C++ Programming Issues

Last reviewed: April 30, 1997
Article ID: Q134819

The information in this article applies to:
  • Microsoft SQL Server, version 6.0

SUMMARY

This article provides information regarding some of the more common errors you may encounter when you attempt to develop a Microsoft SQL Server version 6.0 distributed management objects (SQL-DMO) application.

MORE INFORMATION

  1. Problem:

    OUT OF MEMORY error returned from CoCreateInstance().

    Cause:

    You can encounter this error in a couple of ways. The first is an actual out of memory situation. The second and more common is caused by a missing DLL or invalid SQL-DMO environment.

    Resolution:

    Make sure you do not have a physical memory error. Also ensure that the SQL-DMO environment was properly installed. You must have the SQLSVC32.DLL and the SQLOLE32.DLL files available and in the applications search path. You also need to have used the SQLOLE.REG file to properly register the SQL-DMO objects.

  2. Problem:

    Ordinal 164 could not be located.

    Cause:

    An attempt is made to use a SQL-DMO application without the SQL Server version 6.0 DBLIBRARY DLL file.

    Resolution:

    Install the SQL Server version 6.0 version of the DBLIBRARY, such as NTWDBLIB.DLL.

  3. Problem:

    if(hResult) does not evaluate as expected

    Cause:

    S_OK is equal to zero, so statements such as the following can cause unexpected behavior:

          if(S_OK & hResult)
    

          -OR-
    

          if(hResult)
    

    Resolution:

    Since S_OK is equal to zero, it does not evaluate to a non-zero value, so it evaluates to false and takes the else branch.

    Change statements to look like the following:

          if(S_OK == hResult)
    

    Or, use the SUCCEED macro to check the status.

  4. Problem:

    CoInitialize() returns S_FALSE in an MFC application.

    Cause:

    By default, if you build an MFC project enabled for OLE support, the AfxInitOle() function is called in the CWinApp derived class.

    Resolution:

    Continue to call the CoInitialize function. This will always ensure the initialization has taken place. For instance if the CoUnInitialize() function is invoked and you want to do another CoCreateInstance(), then you must call the CoInitialize() the second time to reinitialize.

  5. Problem:

    Error C2039: 'xxx' : is not a member of 'IASQLOLEServer'

    Cause:

    The specific code line has attempted to directly access an object property.

    Resolution:

    Use the Set and Get methods to access the data.

             pSQLServer->SetApplicationName("SQL_DMO Test");
             pSQLServer->SetHostName("Sample");
    
    


Additional query words: sql6 programming ole 32-bit
Keywords : kbprg SSrvDMO SSrvErr_Log SSrvProg
Version : 6.0
Platform : WINDOWS
Issue type : kberrmsg


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.