Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:11:36+00:00 2026-06-09T07:11:36+00:00

-(IBAction)btnAddToFavorite:(id)sender { [self insertDataToFavourites:[[tempDict objectForKey:@pageid]intValue]:[tempDict objectForKey:@desc]]; } -(void)insertDataToFavourites:(int)pageid :(NSString *)description { sqlite3_stmt *insertStatement =

  • 0
-(IBAction)btnAddToFavorite:(id)sender
{
    [self insertDataToFavourites:[[tempDict objectForKey:@"pageid"]intValue]:[tempDict objectForKey:@"desc"]];
}

-(void)insertDataToFavourites:(int)pageid :(NSString *)description
{
    sqlite3_stmt *insertStatement = nil;
    NSString *sql;
    int returnvalue;
        sql = [NSString stringWithFormat:@"insert into AddFavorite (Id,Description) VALUES (?,?)"];

    returnvalue = sqlite3_prepare_v2(database, [sql UTF8String], -1, &insertStatement, NULL);

    NSLog(@"\nFavorite ID is:--> %d &\nDescription is:--> %@",[[tempDict valueForKey:@"pageid"] intValue] ,[tempDict valueForKey:@"desc"]);

    if (returnvalue == 1){
        NSAssert1 (0,@"Error: failed to prepare statement with message '%s'.", sqlite3_errmsg(database));
    }
    sqlite3_bind_text(insertStatement, 1,[[tempDict objectForKey:@"pageid"] UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_text(insertStatement, 2,[[tempDict objectForKey:@"desc"] UTF8String], -1, SQLITE_TRANSIENT);

    if (SQLITE_DONE != sqlite3_step(insertStatement)){
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));
    }
    else{
        sqlite3_reset(insertStatement);
    }

    sqlite3_finalize(insertStatement);
}

This is a code to insert data into database. It is showing data like this, when i check database using select query.

enter image description here

Can anybody tell me where is the mistake ?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:11:38+00:00Added an answer on June 9, 2026 at 7:11 am

    try to use the pageid method variable and not your dict, maybe the dict is wrong. On the other hand you insert for id

    sqlite3_bind_text(insertStatement, 1,[[tempDict objectForKey:@"pageid"] UTF8String], -1, SQLITE_TRANSIENT);
    

    i think this might be not correct.

    For test case you can insert in SQLiteManager as sqlstatement

    insert into AddFavorite (Id,Description) VALUES (1,’TestDescription’);

    to check if the statement is correct.

    I would use this code to insert your values, if id is an int in your database

    -(void)insertDataToFavourites:(int)pageid :(NSString *)description
    {
       sqlite3 *database;
    
       if(sqlite3_open([self.databasePath UTF8String], &database) == SQLITE_OK) {
    
          const char *sqlStatement = "INSERT INTO AddFavorite (Id,Description) VALUES (?,?);";
    
          sqlite3_stmt *compiled_statement;
          if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiled_statement, NULL) == SQLITE_OK)    {
    
            sqlite3_bind_int(compiled_statement, 1, pageid);
            sqlite3_bind_text(compiled_statement, 2, [description UTF8String] , -1, SQLITE_TRANSIENT);
    
          }
    
          if(sqlite3_step(compiled_statement) != SQLITE_DONE ) {
            NSLog( @"Error: %s", sqlite3_errmsg(database) );
          } else {
            NSLog( @"Insert into row id = %lld", sqlite3_last_insert_rowid(database));
          }
    
          sqlite3_finalize(compiled_statement);
      }
    
      sqlite3_close(database); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my answer: -(IBAction)sortBySelectedFilter { ... [self sortWithKey:@filename ascending:ascending selector:@selector(compareFileType:)]; ... } -(void)sortWithKey:(NSString
-(IBAction)actionPrevious:(id)sender{ [self startact]; pageNumber = pageNumber - 1; if (pageNumber>0) { NSString *str_Img =[array_Image
-(IBAction)registerUpdate:(id)sender { HTTPRequest* request = [[HTTPRequest alloc] initWithUrl:@http://www.yahoo.com delegate:self]; [request doRequest]; } The HTTPRequest
- (IBAction)EnterButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
-(IBAction)_clickautoscroll:(id)sender { NSTimer *autoscrollTimer; if (autoscrollTimer == nil) { autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(55.0/1000.0) target:self
-(IBAction)printDisplay:(id)sender{ CGRect rect = CGRectMake(0.0,44.0,self.view.frame.size.width,self.view.frame.size.height); NSValue *rectObj = [NSValue valueWithCGRect:rect]; CGRect rectRestored = [rectObj
-(IBAction)ButtonPressed:(id)sender { const char *sql = SELECT AccessCode FROM UserAccess; NSString *sqlns; sqlns =
- (IBAction)SetupButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@MoneyofType:@sqlite];
-(IBAction)startClick:(id)sender{ stick.highlighted = YES; } -(void)viewDidLoad{ [super viewDidLoad]; stick = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@ball1.png]]; stick.userInteractionEnabled=

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.