Hi Nikki, Why do we want to use sqlite3_reset() in the for loop? If I leave it in, the loop keeps running forever since I guess it really does keep resetting the sql statement. Do we need it though inside the while loop when SQLITE_BUSY is returned though? Is that the proper way to try again after being busy, or will it again reset the entire statement and throw back to an infiinite loop?
Thanks, Mark On 8/15/06, Nikki Locke <[EMAIL PROTECTED]> wrote:
Mark Wyszomierski wrote: > strSql.Format(_T("SELECT * FROM test")); > > sqlite3_stmt *pStmt; > const char *pszTailPointer; > int nRetVal = sqlite3_prepare(db, strSql, strSql.GetLength(), > &pStmt, &pszTailPointer); > if (nRetVal != SQLITE_OK) { > TRACE("prepare fails!! [%i] [%s]\n", nRetVal, sqlite3_errmsg(db)); > return false; > } > > nRetVal = sqlite3_step(pStmt); > while (nRetVal == SQLITE_BUSY || nRetVal == SQLITE_ROW) { > Sleep(100); > // Try again. > nRetVal = sqlite3_step(pStmt); > // How do I get the information out of this returned record? > > // By the way, why would we want a reset() in here? > // sqlite3_reset(pStmt); > } Your error checking is all wrong. Try something like this... int nRetVal = sqlite3_prepare(db, strSql, strSql.GetLength(), &pStmt, &pszTailPointer); if (nRetVal != SQLITE_OK) { TRACE("prepare fails!! [%i] [%s]\n", nRetVal, sqlite3_errmsg(db)); return false; } for ( ; ; ) { while((nRetVal = sqlite3_step(pStmt)) == SQLITE_BUSY) { Sleep(100); sqlite3_reset(pStmt); // Not sure if this is needed } if (nRetVal != SQLITE_ROW) break; // No more rows, or an error // How do I get the information out of this returned record? sqlite3_reset(pStmt); // Ready for the next sqlite3_step } -- Nikki Locke, Trumphurst Ltd. PC & Unix consultancy & programming http://www.trumphurst.com/ ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------
----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------