Note that there are some explanatory texts on larger screens.

plurals
  1. POSample Application for SQLite
    primarykey
    data
    text
    <p>Hello friends I am developing application in which view has one textField &amp; 2 buttons. When user clicks on "Add" then text from textfield should be stored in datatabse. When user clicks on "Display"then data fetched from database should be displayed in textField. The code written is like this</p> <pre><code>//SettingsApplicationViewController.h #import "FMDatabase.h" @interface SettingsApplicationViewController : UIViewController { FMDatabase *db; IBOutlet UITextField *urlField; IBOutlet UIButton *insertButton; IBOutlet UIButton *displayButton; } @property(nonatomic, retain) IBOutlet UITextField *urlField; @property(nonatomic, retain) IBOutlet UIButton *insertButton; @property(nonatomic, retain) IBOutlet UIButton *displayButton; -(void)insertButtonClicked :(id)sender; -(void)displayButtonClicked:(id)sender; -(id)initApp; @end // SettingsApplicationViewController.m #import "SettingsApplicationViewController.h" #import "FMDatabase.h" @implementation SettingsApplicationViewController @synthesize urlField; @synthesize insertButton; @synthesize displayButton; -(id)initApp { if(![super init]) return nil; //DB stored in application bundle NSString *DBName = @"SettingDB.sqlite"; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingString:DBName]; db = [FMDatabase databaseWithPath:path]; [db setLogsErrors:TRUE]; [db setTraceExecution:TRUE]; if(![db open]) { NSLog(@"Could not open Database"); return 0; } else { NSLog(@"Database opened successfully"); } return self; } - (void)viewDidLoad { [super viewDidLoad]; [self initApp]; } -(void)insertButtonClicked :(id)sender { [db executeUpdate:@"insert into Settings values (?)",urlField.text]; [self resignFirstResponder]; } -(void)displayButtonClicked:(id)sender { NSString *returnResult = [[NSString alloc]init]; FMResultSet *rs = [db executeQuery:@"select url from Settings"]; while ([rs next]) { returnResult = [rs stringForColumn:@"url"]; [urlField setText:returnResult]; } } // SettingDB.sqlite CREATE TABLE Settings(url text(50)); </code></pre> <p>I created connections in IB &amp; copied libsqlite3.dylib &amp; FMDatabase file. I dont know why " # " is not printed in this post but I have # in my code.</p> <p>When I compile this code it is showing 1 error as follows</p> <pre><code>Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1 </code></pre> <p>Please help me friends. Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload