Click here to Skip to main content
13,046,087 members (63,045 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Everyone:

I am trying to delete a SQLite database(file) through C++, which is created using php file. I am getting the SQLITE_BUSY error and was not able to solve it.

Creating the database in PHP:
$dir = 'sqlite:C:/Program Files/x/'.$DataBaseName.'.sqlite';
$database  = new PDO($dir) or die("cannot open the database"); //Database is always created sucessfully here

Accessing and Deleting the database in C++:
   bool delete = false;
   delete = HandleDataBase(name);
      remove(filename);//C++ error 32, file is under use.
    sqlite3 *database;
    if(sqlite3_open(name, &database) == SQLITE_OK)//database exists
	const char *pSQL[6];
        pSQL[0] = "select * from Table1";
        sqlite3_stmt *statement1;
        if ( sqlite3_prepare(database, pSQL[0], -1, &statement1, 0 ) == SQLITE_OK )//i believe this makes the database busy, but how to meake it nonbusy after performing operations 
        int rc = sqlite3_close(database);//failing since the database is busy
	if ( rc == SQLITE_BUSY)
	     bool busy = true;//true, the database here is always busy.
        return true;//delete the database if it exists.
    return false;

How do i solve my issue, how should i close the database after reading and updating information(using sqlite3_prepare) so that i can delete it?
Posted 2-Jul-12 9:40am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use sqlite3_finalize[^] on the prepared statement.
amarasat 5-Jul-12 11:59am
Thanks a lot, using sqlite3_finalize has solved my issue!!
abhishekgour 30-May-13 9:07am
It's solved my iphone sqlite_busy error thanks a lot....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 2 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100