Specified driver could not be located due to system error 5
-
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
-
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
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.
-
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.
But there is no return code m_nRetCode for invalid name and password. Elizabeth
-
But there is no return code m_nRetCode for invalid name and password. Elizabeth
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. -
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.Thank you. Your suggestion works. I got both state codes 28000 and IM006 returned when an invalid user name or password is entered. Elizabeth