Re: [sqlite] when we need to use sqlidte3_close

2008-04-18 Thread Dennis Cote
Joanne Pham wrote:
> The question that I had is when we need to use the sqlite3_close.
> So the question is do we need to use the sqlite3_close and when we need it.

sqlite3_close() closes the database connection opened by sqlite3_open(). 
You use it when you are done with a database connection.

sqlite3_finalize() destroys a statement created by sqlite3_prepare(). 
You do not close these statements.

HTH
Dennis Cote

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] when we need to use sqlidte3_close

2008-04-18 Thread Joanne Pham
Hi All,
The question that I had is when we need to use the sqlite3_close.
The reason that I have this question because I had the following codes and it 
crashed  if the sqlite3_closed is used.
Below is the codes:
.
  sqlSt = sqlite3_prepare_v2(pDb,stmt,-1,,0);
  if (sqlSt != SQLITE_OK ) {
   sqlite3_reset(pReadStmt);
   errMsg = (char *)sqlite3_errmsg(pDb);.
   sqlite3_free(errMsg);
   return false;
  }
  while (!bFinished) {
   sqlSt = sqlite3_step(pReadStmt);
   iColCnt=0;
   switch (sqlSt) {
   case SQLITE_DONE:
bFinished = true;
sqlite3_reset(pReadStmt); // Resets the compited statement for 
re-use
break;
   case SQLITE_ROW:
(get the rows)
   case SQLITE_BUSY: 
  sleep(0);
break;
   default: 
sqlite3_finalize(pReadStmt);
break;
   } // switch
  } // while
  sqlite3_finalize(pReadStmt);
  //sqlite3_close(pDb);
So if I use the sqlite3_close here then the code will be crashed.
So the question is do we need to use the sqlite3_close and when we need it.
Thanks
JP


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users