[摘要]rc == SQL_SUCCESS_WITH_INFO) /*有数据*/ SQLFreeStmt(hstmt_select,SQL_DROP) ; hstmt_select = ... rc == SQL_SUCCESS_WITH_INFO) { /*有数据*/ SQLFreeStmt(hstmt_select,SQL_DROP) ; hstmt_select = NULL ; return lRet ; } else if (rc == 100) { /*没有数据*/ SQLFreeStmt(hstmt_select,SQL_DROP) ; hstmt_select = NULL ; return 0 ; } else if (rc < 0) { /*出错*/ goto end ; } } else { /* SQLExecDirect FALSE */ goto end ; }
end: { m_sErrMsg = "" ; while(SQLError(0, 0, hstmt_select, szSQLSTATE, &nErr, ErrMsg, sizeof(ErrMsg), &cbmsg)==SQL_SUCCESS) m_sErrMsg += "\t\t" + CString(ErrMsg) +"\n" ;
SQLFreeStmt(hstmt_select,SQL_DROP) ; hstmt_select = NULL ; return -1 ; } } /*非常有用函数,用在确保语句句柄释放*/ void CWdcDatabase::DropHstmtSelect() { if(hstmt_select !=NULL) { SQLFreeStmt(hstmt_select,SQL_DROP) ; hstmt_select = NULL ; } } |
关键词: 一个用技巧强大的ODBC API 函数访问数据库类