You need to tell us which APi your using. For error handling you just need to check the return values of the functions you call. Or you should check if they throw exceptions.
The exception and the return value I haved used are not real values I just made them up to show you how to handle the error. Check your documentation for function return values and exceptions.
0
turbot_yuAuthor Commented:
I am using the connection as:
SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv );
SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,SQL_IS_INTEGER );
SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hDbc);
SQLinfo = SQLConnect( hDbc,
(SQLCHAR*)DefServerName,SQL_NTS,
(SQLCHAR*)"h1",SQL_NTS,
(SQLCHAR*)"h1",SQL_NTS );
0
turbot_yuAuthor Commented:
Is it the API?
0
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
When SQLAllocHandle returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling SQLGetDiagRec with the appropriate HandleType and Handle set to the value of InputHandle. SQL_SUCCESS_WITH_INFO (but not SQL_ERROR) can be returned for the OutputHandle argument.
As I said in my first statement "When SQLAllocHandle returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value may be obtained by calling SQLGetDiagRec with the appropriate HandleType and Handle set to the value of InputHandle."
for example:
if(SQLAllocHandle(SQL_HAND
{
failed
some error message
}
or
try
{
SQLAllocHandle(SQL_HANDLE_
lstrcpy( (char *) SqlStmt, "SELECT ");
lstrcat( (char *) SqlStmt, viType);
lstrcat( (char *) SqlStmt, " FROM instance WHERE instid=");
lstrcat( (char *) SqlStmt, db2_instid);
lstrcat( (char *) SqlStmt, ";");
SQLExecDirect(hStmt, SqlStmt, lstrlen((char *)SqlStmt));
SQLBindCol( hStmt,1,SQL_C_CHAR,Timesta
RetCode = SQLFetch( hStmt );
SQLFreeHandle(SQL_HANDLE_S
}
catch(Oracle exception)
The exception and the return value I haved used are not real values I just made them up to show you how to handle the error. Check your documentation for function return values and exceptions.