CODBC_RowResult::CODBC_RowResult( CStatementBase& stmt, SQLSMALLINT nof_cols, SQLLEN* row_count ) : m_Stmt(stmt) , m_CurrItem(-1) , m_EOR(false) , m_RowCountPtr( row_count ) , m_HasMoreData(false) { odbc::TSqlChar column_name_buff[eODBC_Column_Name_Size]; if(m_RowCountPtr) *m_RowCountPtr = 0; SQLSMALLINT actual_name_size; SQLSMALLINT nullable; m_ColFmt = new SODBC_ColDescr[nof_cols]; for (unsigned int n = 0; n < (unsigned int)nof_cols; ++n) { // SQLDescribeCol takes a pointer to a buffer. switch(SQLDescribeCol(GetHandle(), n + 1, column_name_buff, eODBC_Column_Name_Size * sizeof(odbc::TSqlChar), &actual_name_size, &m_ColFmt[n].DataType, &m_ColFmt[n].ColumnSize, &m_ColFmt[n].DecimalDigits, &nullable)) { case SQL_SUCCESS_WITH_INFO: ReportErrors(); case SQL_SUCCESS: m_ColFmt[n].ColumnName = CODBCString(column_name_buff, actual_name_size).ConvertTo(GetClientEncoding()); break; case SQL_ERROR: ReportErrors(); { string err_message = "SQLDescribeCol failed." + GetDbgInfo(); DATABASE_DRIVER_ERROR( err_message, 420020 ); } default: { string err_message = "SQLDescribeCol failed (memory corruption suspected)." + GetDbgInfo(); DATABASE_DRIVER_ERROR( err_message, 420021 ); } } m_CachedRowInfo.Add( m_ColFmt[n].ColumnName, m_ColFmt[n].ColumnSize, s_GetDataType(m_ColFmt[n].DataType, m_ColFmt[n].DecimalDigits, m_ColFmt[n].ColumnSize) ); } }
CMySQL_RowResult::CMySQL_RowResult(CMySQL_Connection& conn) : m_Connect(&conn), m_CurrItem(-1) { m_Result = mysql_use_result(&m_Connect->m_MySQL); if ( !m_Result ) { DATABASE_DRIVER_WARNING( "Failed: mysql_use_result", 800004 ); } unsigned int col_num = mysql_num_fields(m_Result); MYSQL_FIELD* fields = mysql_fetch_fields(m_Result); for (unsigned int n = 0; n < col_num; n++) { m_CachedRowInfo.Add( fields[n].name, fields[n].max_length, s_GetDataType(fields[n].type) ); } }