简体   繁体   English

如果我调用此方法,那么我将收到一个错误消息,即“数据库已锁定”。我该如何解决呢? 请帮我

[英]If i call this method,then i'm getting a error which is “database is lock”.How i can solve this?? Please help me

If I call -(void)insertDataIntoAssemblyAssessment method,where finalAssembIdArr is an array in which must be more than one value, then i'm getting a error which is " database is lock ". 如果我调用-(void)insertDataIntoAssemblyAssessment方法,其中finalAssembIdArr是一个数组,其中必须有多个值,那么我将得到一个错误,即“ 数据库已锁定 ”。 But, if in finalAssembIdArr have just one value,then,value are stored in database successfully. 但是,如果finalAssembIdArr中只有一个值,则该值将成功存储在数据库中。

How I can solve this?? 我该如何解决? Please help me. 请帮我。

-(void)insertDataIntoAssemblyAssessment
{
    sqlite3_stmt *fstatement;
    const char *dbpath = [databasePath UTF8String];
    for(int cnt=0; cnt < [finalAssembIdArr count]; cnt++)
    {
        finalAsmbId2=[finalAssembIdArr objectAtIndex:cnt];

        NSLog(@"finalAsmbId2...%@",finalAsmbId2);
        NSLog(@"finalAssessmentIdSt2...%@",finalAssessmentIdSt2);
        NSLog(@"finalFacIdSt2...%@",finalFacIdSt2);
        NSLog(@"finalSpaceIdSt2...%@",finalSpaceIdSt2);

        if (sqlite3_open(dbpath, &ipadSites) == SQLITE_OK)
        {
            NSLog(@"db opened for AssemblyAssessment..");

            NSString *insertfSQL = [NSString stringWithFormat:@"INSERT INTO AssemblyAssessment (assessmentid,spaceid,assemblyid,FacilityID) VALUES (\"%@\",\"%@\",\"%@\",\"%@\")",self.finalAssessmentIdSt2,self.finalSpaceIdSt2,self.finalAsmbId2,self.finalFacIdSt2];

            NSLog(@"insertfSQL...%@",insertfSQL);


            const char *insert_fstmt = [insertfSQL UTF8String];
                sqlite3_prepare_v2(ipadSites,insert_fstmt,-1,&fstatement,NULL);
                NSLog(@"inserting AssemblyAssessment..");

            if (sqlite3_step(fstatement) == SQLITE_DONE)
            {
                NSLog(@"Add value in AssemblyAssessment...");

            }
            else
            {
                NSLog(@"Insert failed: %s", sqlite3_errmsg(ipadSites));
                NSLog(@"Failed to add value in AssemblyAssessment...");
            } 
        }

        sqlite3_finalize(fstatement);
        sqlite3_close(ipadSites);

    }
}

Please... ! 请... ! Don't open/close SQLite connection in loop like that! 不要像这样循环地打开/关闭SQLite连接! Open handle to database outside from the "FOR loop". 从“ FOR循环”外部打开数据库的句柄。 Please look here how to insert data into data base in iphone and here How to insert NSMutableArray elements in Sqlite3 in iPhone 请查看此处如何将数据插入到iphone的数据库中,以及此处如何在iPhone的Sqlite3中插入NSMutableArray元素

And, for the basic CRUD (create, read, update, delete), I suggest you .. to take a look at FMDB 而且,对于基本的CRUD(创建,读取,更新,删除),我建议您..看一下FMDB。

Have you opened the database in SQLite or any other browser ?? 您是否已在SQLite或任何其他浏览器中打开了数据库? If database is opened from outside, it gives same error. 如果从外部打开数据库,则会出现相同的错误。 Check it. 核实。 I had same issue. 我有同样的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将此JSON数据放入我的表视图中? 请帮助我,我生活在一场噩梦:) - How do I put this JSON data into my table view? Please help me, I'm living in a nightmare :) 我正在尝试使用此代码进行网格视图动画,但是我没有使用此代码进行网格视图动画。您能帮我吗? - i'm trying to do grid view animation with this code,but i'm not getting grid view animation with this code.can you help me how? 当我调用方法[self somemethod]时如何解决错误 - How to solve a error when I call the method [self somemethod] 您好我正在尝试执行Wikitude示例应用程序,但我收到这些编译错误,请帮助我 - Hi I am trying to execute the Wikitude sample application, but I am getting these compile errors, please help me in this 我正在以UTF 8格式获取标题的json数据,那么如何解决呢? - I m getting json data for title in UTF 8 format, then how solve it? 我在哪里发布这个对象。请帮帮我? - Where I release this object.Please help me? 我必须在哪里声明 MPMoviePlayer 的通知功能。 请帮我 - Where i have to declare the notification functions of MPMoviePlayer . Please help me 如何制作我的UISwitch调用方法(我在使用theos) - How can I make my UISwitch call method (I'm using theos) 我正在构建录音机,当我在 ios 6 中使用音频演示库时出现问题。任何人都可以帮助解决我的问题吗? - I am building voice recorder in which i m getting issue when i am using Audio Demo library in ios 6. Can anyone help in clearing my issue? 如何解决此错误:“预期标识符” - How can I solve this error: “Expected identifier”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM