|
Home > Archive > MS SQL Server ODBC > October 2006 > ODBC BCP Error Handling in C++
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
ODBC BCP Error Handling in C++
|
|
| TLunsf 2006-10-24, 6:40 pm |
| (Please let me know if there is a better group to post this on...)
I have written a C++ program that BCP's data into SQL Server using ODBC.
I'm currently at the point that I am testing worst-case scenarios. In the
scenario that while the BCP is running, I pull the network cable from SQL
server, I get failed calls to bcp_sendrow, but I am unable to get details on
the error. I have tried calling SQLGetDiagRec with handle types of
SQL_HANDLE_ENV, SQL_HANDLE_DBC, and SQL_HANDLE_STMT.
Any suggestions would be appreciated.
Thanks.
-Thomas
| |
| TLunsf 2006-10-24, 6:40 pm |
| I figured it out myself. In case anyone is interested, here is how to
determine whether the connection to the database is still alive...
SQLHDBC m_hConn;
...
SQLINTEGER siDead = SQL_CD_FALSE;
::SQLGetConnectAttr(
m_hConn
,SQL_ATTR_CONNECTION
_DEAD
,&siDead //SQL_CD_TRUE or SQL_CD_FALSE
,sizeof(siDead)
,NULL);
if (siDead == SQL_CD_TRUE)
{
//Database connection is dead
}
|
|
|
|
|