Cian 0 Posted May 27, 2016 Share Posted May 27, 2016 (edited) Hello Guys, I want read a Vnum from Database... However it does not work. My Source code : Spoiler long CItem::GetPetVnum() { char Query[1024 + 1]; snprintf(Query, sizeof(Query), "SELECT Petvnum FROM pet_summon WHERE PetSummonItemVnum='%d'", GetVnum()); std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(Query)); MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult); long alrow = atoi(row[0]); sys_log(0, "TEST_VNUM : %d\n", alrow); return alrow; } What is wrong? Thanks for your help! Sorry for my bad English .. Edited August 20, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Fazer 701 Posted May 27, 2016 Share Posted May 27, 2016 long CItem::GetPetVnum() { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT Petvnum FROM pet_summon WHERE PetSummonItemVnum='%d'", GetVnum()); std::auto_ptr<SQLMsg> msg(CDBManager::instance().DirectQuery(szQuery)); MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); long alrow = atoi(row[0]); sys_log(0, "TEST_VNUM : %d\n", alrow); return alrow; } try this 1 Link to comment Share on other sites More sharing options...
Active Member hachiwari 138 Posted May 28, 2016 Active Member Share Posted May 28, 2016 9 minutes ago, Fazer said: try this long CItem::GetPetVnum() { char szQuery[1024 + 1]; snprintf(szQuery, sizeof(szQuery), "SELECT Petvnum FROM pet_summon WHERE PetSummonItemVnum='%d'", GetVnum()); std::auto_ptr<SQLMsg> msg(CDBManager::instance().DirectQuery(szQuery)); MYSQL_ROW row = mysql_fetch_row(pMsg->Get()->pSQLResult); long alrow = atoi(row[0]); sys_log(0, "TEST_VNUM : %d\n", alrow); return alrow; } change name?XDDD #topic try this long CItem::GetPetVnum() { char szQuery[1024]; snprintf(szQuery, sizeof(szQuery), "SELECT Petvnum FROM pet_summon WHERE PetSummonItemVnum = %u LIMIT 1", GetVnum()); std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery(szQuery)); if (msg->Get()->uiNumRows > 0) { MYSQL_ROW row = mysql_fetch_row(msg->Get()->pSQLResult); long alrow = atoi(row[0]); sys_log(0, "TEST_VNUM : %l\n", alrow); return alrow; } else return -1; } 1 Link to comment Share on other sites More sharing options...
Cian 0 Posted May 28, 2016 Author Share Posted May 28, 2016 Thanks all for help ! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now