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

  • Home
  • SEARCH
  • 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 8233861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:16:22+00:00 2026-06-07T18:16:22+00:00

I am trying to take text that the user inputs in a text view

  • 0

I am trying to take text that the user inputs in a text view section (outlet named viewNotes) and put it into a DB after clicking a submit button. When I run the app it works fine until I hit submit and then I get a crash (breakpoint) on the sqlite3_bind_text function. I can’t figure out what I’m doing wrong. Here is the action code:

- (IBAction)submitNotes:(id)sender {
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDir stringByAppendingPathComponent:@"highpeaks.db"];

sqlite3 *database;
sqlite3_stmt *theNewStmt;
if(sqlite3_open([path UTF8String], &database) == SQLITE_OK)
{
    const char *sql = "UPDATE Peaks SET notes=? WHERE ID=?";
    if(sqlite3_prepare_v2(database, sql, -1, &theNewStmt, NULL) != SQLITE_OK)
        NSLog(@"Error while creating update statement. %s", sqlite3_errmsg(database));
}
NSLog(@"%@",self.viewNotes.text);
sqlite3_bind_text(theNewStmt, 1, [self.viewNotes.text UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_int(theNewStmt, 2, [self.detailItem ID]);

char* errmsg;
sqlite3_exec(database, "COMMIT", NULL, NULL, &errmsg);

if(SQLITE_DONE != sqlite3_step(theNewStmt))
    NSLog(@"Error while updating. %s", sqlite3_errmsg(database));
sqlite3_finalize(theNewStmt);

sqlite3_close(database);
}
  • 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-07T18:16:24+00:00Added an answer on June 7, 2026 at 6:16 pm

    I am not entirely sure what was wrong with the above code, but this code works just fine:

    sqlite3_stmt *stmt=nil;
    sqlite3 *cruddb;
    
    //insert
    const char *sql = "UPDATE Peaks SET notes=? where ID=?";
    
    //Open db
    NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    NSString *cruddatabase = [docsDir stringByAppendingPathComponent:@"highpeaks.db"];
    
    sqlite3_open([cruddatabase UTF8String], &cruddb);
    sqlite3_prepare_v2(cruddb, sql, -1, &stmt, NULL);
    sqlite3_bind_text(stmt, 1, [self.viewNotes.text UTF8String], -1, SQLITE_TRANSIENT);
    sqlite3_bind_int(stmt, 2, [self.detailItem ID]);
    
    sqlite3_step(stmt);
    sqlite3_finalize(stmt);
    sqlite3_close(cruddb);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying take the names that I am given by the program after it
I am trying to do the following. Take a block of text that a
I’m trying to make something that will take lines of input from the user,
In this loop, I'm trying to take user input and continually put it in
I'm trying to make a form that will take given text and direct you
I'm trying to take a user input, turn it into a JS variable, and
I'm trying to take a text string, (e.g. the word testing) and calculating if
Context: I'm trying to do is to make a program which would take text
I am trying to take a line of text like 13) Check for orphaned
All, I am trying to create a table to receive user inputs (UGC). This

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.