I try to connect sql server using qt libraries. My driver is ODBC and qt is installed on windows.
I return 0 if connection OK or i return error number otherwise.
If i use wrong user name, password or driver name i have error number which is different form 0.
But when DSN name or server name is wrong i get 0 as error number. How can i handle error number for these situations? I try to catch error number through QSqlDatabase object.
Qt Code:
int returnValue = 0; mSqlDatabase.setHostName("SERVER01"); mSqlDatabase.setDatabaseName("DSNName"); mSqlDatabase.setUserName("userName"); mSqlDatabase.setPassword("password"); if(!mSqlDatabase.open()) { returnValue = mSqlDatabase.lastError().number(); } return returnValue;To copy to clipboard, switch view to plain text mode
Bookmarks