Apr 8, 2012

How to Edit SQL on an iPhone

,


Whether it's user preferences or your own iPhone app data, you must save the changes in the iPhone's SQL database. The iPhone uses a lightweight version of the SQL database software called SQLi. The iPhone connects to the database using internal drivers, and you run the procedure to update the iPhone settings. The update usually occurs after you tap a button.

Instructions

    • 1
      Open the Xcode editor for the iPhone SDK and open your iPhone app project. Double-click the code file to load the current code in the editor.
    • 2
      Create a button to prompt the user to edit the data in the SQL database. Copy and paste the following code to create the button:
      (void)viewDidLoad {
      [super viewDidLoad];
      self.navigationItem.rightBarButtonItem = self.editButtonItem;
      }
    • 3
      Edit the data in the in the SQL database. The following code changes the SQL key named "name" in the iPhone database:
      evController.keyOfTheFieldToEdit = @"name";
      evController.editValue = textbox.name;
      Replace "textbox" with the name of the text box field that contains the update data.
    • 4
      Run the SQL query on the database to complete the changes. Add the following code to execute the SQL statement:
      const char *sql = "update user Set name = ?, Price = ? Where id= ?";
      isqlite3_prepare_v2(database, sql, -1, &updateStmt);
 

HowToYo Copyright © 2011 | Template design by O Pregador | Powered by Blogger Templates