Another tactic: ?why not try a simple query such as "SELECT SQLITE_VERSION()"? ?If you get a decent answer you have verified your connection and can execute your actual query.
On Tuesday, March 1, 2016 2:41 PM, Keith Medcalf <kmedcalf at dessus.com> wrote: After you close the connection and verify the return code, why not set the pointer to 0 (NULL).? In that way you will know that the handle is no more valid rather than just hoping and praying that it is? > -----Original Message----- > From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users- > bounces at mailinglists.sqlite.org] On Behalf Of a a > Sent: Tuesday, 1 March, 2016 10:13 > To: SQLite mailing list > Subject: Re: [sqlite] How to check if connection to main database is still > open or closed before new query ? > > Let me explain it better cause i got confused and i am a? newbie also. > > I open a connection like this > > sqlite3 *ppDB; > int dbcon; >? dbcon = sqlite3_open(databasename, &ppDB); > /// i do my code i query the database i do some stuff and i close the > database like this > dbcon = sqlite3_close(ppDB); > > I want to check after a while if the connection is allready closed or not > for the simple reason not to reopen the database but if is open to run a > query or if it is closed > to reopen the database and then run the query. > > so i think the dbcon is the one i have to check not the ppDB :/ > > it works now maby i didnt understand what ppDB you were reffering to > > if(dbcon){ > //is open > }else{ > //is closed > } > > :) thanks though it is tested and runs ok > > ________________________________________ > From: sqlite-users-bounces at mailinglists.sqlite.org <sqlite-users- > bounces at mailinglists.sqlite.org> on behalf of Simon Slavin > <slavins at bigfraud.org> > Sent: Tuesday, March 1, 2016 7:01 PM > To: SQLite mailing list > Subject: Re: [sqlite] How to check if connection to main? ? ? ? database > is? ? ? still? open or closed before new query ? > > On 1 Mar 2016, at 4:59pm, a a <NoCos30 at hotmail.com> wrote: > > > the sqlite3_close() <--- needs one argument if i pass > sqlite3_close(NULL) it actually closes again a closed connection ? > > No.? If you pass it null it realises that the connection is closed and > does nothing. > > Simon. > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users at mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users