|
AppBuilder中进行直接ODBC API数据库调用访问的基本方法!(11) CDData_aBeiZhu_SIZE,0, HostData.m_Abeizhu, 0,&HostData.m_AbeizhuInd );
}
// Move the data to host structure and execute the statement HostData.m_Nguangpan = pData->m_Nguangpan; HostData.m_Nwenjian = pData->m_Nwenjian; HostData.m_Nclass = pData->m_Nclass; HostData.m_AwenjianInd = SQL_NTS; memcpy(HostData.m_Awenjian, pData->m_Awenjian, CDData_aWenJian_SIZE); HostData.m_Nshangji = pData->m_Nshangji; HostData.m_Nshuxing = pData->m_Nshuxing; HostData.m_AbeizhuInd = SQL_NTS; memcpy(HostData.m_Abeizhu, pData->m_Abeizhu, CDData_aBeiZhu_SIZE);
ReturnCode = SQLExecute(m_hstmt); if (ReturnCode != SQL_SUCCESS) { return false; }
return true;
}
九、其他操作:
1、检测SQL错误: void DisplayError(SQLRETURN nResult, SWORD fHandleType, SQLHANDLE handle) { UCHAR szErrState[SQL_SQLSTATE_SIZE+1]; // SQL Error State string UCHAR szErrText[SQL_MAX_MESSAGE_LENGTH+1]; // SQL Error Text string char szBuffer[1000]; char szDispBuffer[1000]; // Display Buffer // formatted Error text Buffer SWORD wErrMsgLen; // Error message length long dwErrCode; // Native Error code int iSize; // Display Error Text size SQLRETURN nErrResult; // Return Code from SQLGetDiagRec SWORD sMsgNum = 1; SWORD fFirstRun = TRUE;
szBuffer[0] = '\0';
do { // continue to bring messageboxes till all errors are displayed. // more than one message box may be reqd. as err text has fixed // string size.
// initialize display buffer with the string in error text buffer strcpy(szDispBuffer, szBuffer);
// call SQLGetDiagRec function with proper ODBC handles, repeatedly until // function returns SQL_NO_DATA. Concatenate all error strings // in the display buffer and display all results. while ((nErrResult = SQLGetDiagRec(fHandleType, handle, sMsgNum++, szErrState, &dwErrCode, szErrText, SQL_MAX_MESSAGE_LENGTH-1, &wErrMsgLen)) != SQL_NO_DATA) {
|