SQLite,sqlite_busy:无法删除数据库 [英] SQLite, sqlite_busy: Unable to delete the database

查看:444
本文介绍了SQLite,sqlite_busy:无法删除数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:

我正在尝试通过C ++删除使用php文件创建的SQLite数据库(文件).我收到SQLITE_BUSY错误,但无法解决.

用PHP创建数据库:

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



在C ++中访问和删除数据库:



Accessing and Deleting the database in C++:

function1()
{
   bool delete = false;
   delete = HandleDataBase(name);
   if(delete)
      remove(filename);//C++ error 32, file is under use.
}

HandleDataBase(name)
{
    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?

推荐答案

dir = ' sqlite:C:/Program Files/x/'.


DataBaseName.' .sqlite';
DataBaseName.'.sqlite';


数据库 = PDO(


这篇关于SQLite,sqlite_busy:无法删除数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆