INF: Extended Procedure Error: "Cannot find the DLL 'xxx.dll'" (151596)



The information in this article applies to:

  • Microsoft SQL Server 6.0
  • Microsoft SQL Server 6.5
  • Microsoft SQL Server 7.0
  • Microsoft SQL Server 2000 (all editions)

This article was previously published under Q151596

SUMMARY

SQL Server generically returns this error message when there is a problem loading the extended stored procedure:
"Cannot find the DLL 'xxx.dll'"

MORE INFORMATION

There are several problems that you might experience. Among these are:
  • DLL not in the correct path.
  • Subsidiary DLLs, like MFC40.dll, not in the path.
  • Function not found.
  • Any other error that would cause the loading of the extended stored procedure DLL to fail.


There are a couple of techniques that you can use to identify the errors. First, you need to re-visit the path and make sure the DLL is in the path. Also double check the sp_helptext stored procedure for the procedure to make sure the name is correct.

If these efforts still do not identify the problem, you may be able to use the following code snippet to identify the error. The code loads the specified library, and tries to access the function. If it fails to load, it will print the associated operating system error message.
#include "windows.h"
#include "stdio.h"

// 
//    Functions
// 

typedef int (*fnInternal)(void);
void main(int iArgs, char *strArgs[], char *strEnvs[]);
void vUsage(void);

// 
//    Main function
// 
void main(int iArgs, char *strArgs[], char *strEnvs[])
{
   HINSTANCE   hLib        =  NULL;
   fnInternal  fCall       =  NULL;
   char     strMsg[1025]   =  "";

   if(iArgs == 3)
   {
      printf("\nAttempting to load %s - %s\n",
               strArgs[1], strArgs[2]);
      if( (hLib = LoadLibrary(strArgs[1])) != NULL)
      {
         fCall = (fnInternal)GetProcAddress(hLib, strArgs[2]);
         if(fCall)
         {
            printf("%s found and loaded successfully.\n",
strArgs[2]);
         }
         else
            printf("%s not found in %s.\n", strArgs[2],
strArgs[1]);
         FreeLibrary(hLib);
      }
      else
      {
         ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                     NULL,
                     GetLastError(),
                     GetSystemDefaultLangID(),
                     strMsg,
                     sizeof(strMsg) -1,
                     NULL);
         printf("Error %ld %s\n", GetLastError(), strMsg);
      }
   }
   else
      vUsage();

   printf("\n");
}

// 
//    vUsage
// 
void vUsage(void)
{
   printf("\n"
         "Usage: Loadlib.exe libname function\n"
         "\n"
         "Where: libname  = 8.3 name of library\n"
         "       function = name of function in the library\n"
         "\n"
         "Example: loadlib xplog70.dll xp_msver\n");
}
				

Modification Type:MajorLast Reviewed:12/3/2003
Keywords:kbinfo kbprogramming KB151596