Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Specified driver could not be located due to system error 5

Specified driver could not be located due to system error 5

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelptestingbeta-testing
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ElizabethC
    wrote on last edited by
    #1

    I am testing my application on different client machines. The application got into an infinate loop when trying to open the database using ODBC. The error message says "Specified driver could not be located due to system error 5...". I am trying to track it down to exit the application when this occurs, but need help figuring out the value at m_nRetCode. There is a bunch of them from MSDN library. I tried catch(CDBException* e) { //exit if not invalid user name and password if (e->m_nRetCode==AFX_SQL_ERROR_API_CONFORMANCE || e->m_nRetCode == AFX_SQL_ERROR_CONNECT_FAIL || e->m_nRetCode == SQL_INVALID_HANDLE || e->m_nRetCode == AFX_SQL_ERROR_ODBC_LOAD_FAILED || e->m_nRetCode == AFX_SQL_ERROR_SQL_CONFORMANCE) { AfxMessageBox("Database Logon Error - " + e->m_strError); exit(1); return NULL; } else AfxMessageBox("Database Logon Error, invalid user name or password - " + e->m_strError); goto TRY_AGAIN; } But none of these is the correct one. -Elizabeth Elizabeth

    A 1 Reply Last reply
    0
    • E ElizabethC

      I am testing my application on different client machines. The application got into an infinate loop when trying to open the database using ODBC. The error message says "Specified driver could not be located due to system error 5...". I am trying to track it down to exit the application when this occurs, but need help figuring out the value at m_nRetCode. There is a bunch of them from MSDN library. I tried catch(CDBException* e) { //exit if not invalid user name and password if (e->m_nRetCode==AFX_SQL_ERROR_API_CONFORMANCE || e->m_nRetCode == AFX_SQL_ERROR_CONNECT_FAIL || e->m_nRetCode == SQL_INVALID_HANDLE || e->m_nRetCode == AFX_SQL_ERROR_ODBC_LOAD_FAILED || e->m_nRetCode == AFX_SQL_ERROR_SQL_CONFORMANCE) { AfxMessageBox("Database Logon Error - " + e->m_strError); exit(1); return NULL; } else AfxMessageBox("Database Logon Error, invalid user name or password - " + e->m_strError); goto TRY_AGAIN; } But none of these is the correct one. -Elizabeth Elizabeth

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      How about using the reverse approach ? Take the return code of an 'invalid user name or password' event, fire the messagebox and goto TRY_AGAIN if this code equals the exception's return value. If it does not, fire a message box saying 'unspecified database error' and get the error string like you now do and exit the application. In means of implementation, this is just about reversing the if-clauses. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      E 1 Reply Last reply
      0
      • A Antti Keskinen

        How about using the reverse approach ? Take the return code of an 'invalid user name or password' event, fire the messagebox and goto TRY_AGAIN if this code equals the exception's return value. If it does not, fire a message box saying 'unspecified database error' and get the error string like you now do and exit the application. In means of implementation, this is just about reversing the if-clauses. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

        E Offline
        E Offline
        ElizabethC
        wrote on last edited by
        #3

        But there is no return code m_nRetCode for invalid name and password. Elizabeth

        A 1 Reply Last reply
        0
        • E ElizabethC

          But there is no return code m_nRetCode for invalid name and password. Elizabeth

          A Offline
          A Offline
          Antti Keskinen
          wrote on last edited by
          #4

          For all possible ODBC error codes, you can see the MSDN for ODBC Programmer's Reference Appendix A: ODBC Error Codes. In order to see the true error caused by your application, catch all return values by type SQL_ERROR and then seeing CDBException::m_strStateNativeOrigin. In this string, the first 'State' string can be found from the ODBC Error Codes list. From the forementioned list, the state code 08004 means 'Server rejected the connection'. This, by using free intrepretation, can be understood as 'Invalid logon' as well. There is an ODBC Query Tool around in CodeProject that has a source code attached. If you can't find any other solution, try browsing through this source code and seeing how it handles return values from the ODBC driver manager. The tool's page can be found from here[^]. Written by George Poulose. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

          E 1 Reply Last reply
          0
          • A Antti Keskinen

            For all possible ODBC error codes, you can see the MSDN for ODBC Programmer's Reference Appendix A: ODBC Error Codes. In order to see the true error caused by your application, catch all return values by type SQL_ERROR and then seeing CDBException::m_strStateNativeOrigin. In this string, the first 'State' string can be found from the ODBC Error Codes list. From the forementioned list, the state code 08004 means 'Server rejected the connection'. This, by using free intrepretation, can be understood as 'Invalid logon' as well. There is an ODBC Query Tool around in CodeProject that has a source code attached. If you can't find any other solution, try browsing through this source code and seeing how it handles return values from the ODBC driver manager. The tool's page can be found from here[^]. Written by George Poulose. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

            E Offline
            E Offline
            ElizabethC
            wrote on last edited by
            #5

            Thank you. Your suggestion works. I got both state codes 28000 and IM006 returned when an invalid user name or password is entered. Elizabeth

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups