2

I want to insert and update and delete and select the 1000 record in database. When and where i want open and close the database connection. i insert and update and delete the data in database but i error "Out of Memory","Unable to open the database file","Locked Database" this kind of error raise from my side. How to resolve this problem please help guys..

2
  • 1
    Please be more specific. Commented Aug 27, 2012 at 5:50
  • 1
    why every time we give the sqlite open and close for inserting, updating and deleting from web server. Multiple time open and close is running why we give common declaration for this. Commented Aug 27, 2012 at 9:21

2 Answers 2

1

Hey raj whenever you going to deal with the database you firstly open the database Open db and after making changes you must close the database by calling Close Db method. Here are some links for using sqlite in iPhone

http://www.techotopia.com/index.php/An_Example_SQLite_based_iPhone_Application

http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/

http://blog.saers.com/archives/2008/03/14/sqlite-for-iphone-sdk/

http://how2s.org/index.php/How_to_get_started_with_SQLite_on_the_iPhone

i think it helps you.

Sign up to request clarification or add additional context in comments.

1 Comment

I commonly use sqlite3 object and sqlite statement and query string for database connection and processing step. Is it correctly im using or not.
0
NSData *d=UIImageJPEGRepresentation(image, 0.50);

    [dm writeImageInTable:[Base64 encode:d]];


-(void)writeImageInTable:(NSString *)imageString
{

    if (sqlite3_open([DB_PATH UTF8String], &database)==SQLITE_OK)
    {

        NSString *str=[NSString stringWithFormat:@"INSERT INTO imageTable (image) VALUES('%@')",imageString];
       //  NSLog(@"%@",str);
       const char *getFolderQuery=[str UTF8String];

       if(sqlite3_prepare_v2(database, getFolderQuery, -1, &queryForImage, NULL)==SQLITE_OK)
        {
             NSLog(@"test");
             int queryResult;
             if((queryResult=sqlite3_step(queryForImage)) == SQLITE_DONE)
             {
                 NSLog(@"sqlite done insert");
             }
             NSLog(@"sqlite error inside %s", sqlite3_errmsg(database));
         }
         sqlite3_reset(queryForImage);
         sqlite3_finalize(queryForImage);
         NSLog(@"sqlite error %s", sqlite3_errmsg(database));
         sqlite3_finalize(queryForImage);
    }
    else
    {

    }
    if(sqlite3_close(database)==SQLITE_OK)
    {
        NSLog(@"database closed");
    }
    else
    {
        NSLog(@"database still open with error %s",sqlite3_errmsg(database));
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.