int GetPopList_show(PSTRU_ODBC_POP_LIST * appstruGasInfo) { char lc_sql_state_count[SQLSTATESIZE] = {0}; char lc_sql_state[SQLSTATESIZE] = {0}; DBINT result_code = 0; int liCount = 0; DBPROCESS* dbprocess = NULL; try { //查询数据库 dbprocess = goDBConnectionPool.GetDBProcess(); if ( dbprocess == NULL ) return -1; strcpy(lc_sql_state_count, "select count(*) from dbo.t_game_pop_list (nolock) "); dbcmd( dbprocess, lc_sql_state_count ); if( dbsqlexec(dbprocess) == FAIL ) { printf( "Query count(*) failed!\n" ); return -1; } if ( (result_code = dbresults(dbprocess)) != NO_MORE_RESULTS ) { if (result_code == SUCCEED) { dbbind(dbprocess, 1, INTBIND, (DBINT)0, (BYTE*)&liCount); } else { printf( "result_code != SUCCEED!\n" ); return -1; } } else { return -1; } while( dbnextrow(dbprocess) != NO_MORE_ROWS ) { } printf( "t_chat_label_list liCount:%d\n", liCount ); sprintf( lc_sql_state, "select top %d user_id, user_level from dbo.t_game_pop_list with (nolock)", liCount ); dbcmd( dbprocess, lc_sql_state ); if( dbsqlexec(dbprocess) == FAIL ) { printf( "Query top * failed!\n" ); return -1; } PSTRU_ODBC_POP_LIST lpstruGasInfo = NULL; lpstruGasInfo = new STRU_ODBC_POP_LIST; if ( lpstruGasInfo == NULL ) return -1; memset( lpstruGasInfo, 0, sizeof(STRU_ODBC_POP_LIST) ); char strUserId[32] ={0}; while ( (result_code = dbresults(dbprocess)) != NO_MORE_RESULTS ) { if( result_code == SUCCEED ) { //dbbind(dbprocess, 1, INTBIND, (DBINT)0, (BYTE*)&(lpstruGasInfo->mi64UserId)); dbbind(dbprocess, 1, STRINGBIND, (DBINT)0, (BYTE*)strUserId); dbbind(dbprocess, 2, TINYBIND, (DBTINYINT)0, (BYTE*)&(lpstruGasInfo->mbyUserLevel)); } else { break; } } PSTRU_ODBC_POP_LIST lpstruGasInfoTemp = NULL; lpstruGasInfoTemp = new STRU_ODBC_POP_LIST[liCount]; if ( lpstruGasInfoTemp == NULL ) return -1; memset( lpstruGasInfoTemp, 0, liCount*sizeof(STRU_ODBC_POP_LIST) ); *appstruGasInfo = lpstruGasInfoTemp; int n = 1; while( dbnextrow(dbprocess) != NO_MORE_ROWS ) { memcpy( &lpstruGasInfoTemp[n-1], lpstruGasInfo, sizeof(STRU_ODBC_POP_LIST) ); lpstruGasInfoTemp[n-1].mi64UserId = _atoi64(strUserId); memset(strUserId,0,sizeof(strUserId)); memset( lpstruGasInfo, 0, sizeof(STRU_ODBC_POP_LIST) ); n++; } if ( lpstruGasInfo ) delete lpstruGasInfo; return liCount; } catch (...) { return -1; } }