ODBC CGI Exiting Unexpectedly
I have a cgi program written in visual c++ 6 which makes multiple connections through odbc to a sql server db. this works fine when odbc is connecting to a sqlserver that is on the same machine. However, when i change the odbc to connect to a remote server and there are a number of these cgi's running, one or more of the cgi programs can sometime terminate. In the iis log file it says they have a http 502.2 status. I've put some debugs in and it seems to be getting as far as the SQLConnect stage and then something happens which kills the cgi. Any ideas why this is happening? or is there anyway I can debug this further.
here is the code I'm using to connect :
int nConnect=SQLAllocEnv( &m_hEnv );
if( nConnect==SQL_SUCCESS ) {
nConnect=SQLAllocConnect( m_hEnv,&m_hDBC );
if( nConnect==SQL_SUCCESS ) {
SQLSetConnectOption( m_hDBC,SQL_LOGIN_TIMEOUT,5 );
// Connect to the datasource.
_TUCHAR *psvSource=new _TUCHAR[ strlen( svSource )+1 ];
_TUCHAR *psvUser=new _TUCHAR;
_TUCHAR *psvPassword=new _TUCHAR;
strcpy( (char*)psvSource,svSource );
nConnect=SQLConnect( m_hDBC,psvSource,SQL_NTS,psvUser,SQL_NTS,psvPassword,SQL_NTS );
if( nConnect==SQL_SUCCESS || nConnect == SQL_SUCCESS_WITH_INFO ) {
// Now that the datasource is open, get our SQL statement handle.
nConnect=SQLAllocStmt( m_hDBC,&m_hStmt );
}
delete psvSource;
delete psvUser;
delete psvPassword;
}
else
DisplayError();
}
else
DisplayError();