all groups > sql server odbc > september 2006 >
You're in the

sql server odbc

group:

ODBC BCP Error Handling in C++



ODBC BCP Error Handling in C++ TLunsf
9/20/2006 11:34:01 PM
sql server odbc: (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
RE: ODBC BCP Error Handling in C++ TLunsf
9/21/2006 3:41:01 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
}
AddThis Social Bookmark Button