thanks a lot Jean-Denis............

On Thu, May 19, 2011 at 12:49 PM, Jean-Denis Muys <jdm...@kleegroup.com>wrote:

>
> On 19 mai 2011, at 11:21, irfan khan wrote:
>
> Hi,
>
> We got a new iPad and have to test sqllite database.
> Could you please guide me to test.
> Basically I want to create database, create tables insert some
> records, and fetch records from iPad itself.
> Is there any way to create database on iPad for preinstalled sqlite.
>
> SQLite is a C library.
>
> On the iPad as on any other machine, you create an SQLite database using
> that library. Here is the routine in my iPad application that creates a
> database:
>
> - (MyClass *) initWithObject:(MyObject*) objectToManage
> {
> if ((self = (MyClass*)[super initWithObject: objectToManage])) {
>
> NSString *dirPath = objectToManage.absoluteDirPath;
> NSString *sourceFilePath = [dirPath stringByAppendingPathComponent:
> objectToManage.fileName];
> NSString *basePath = [sourceFilePath stringByDeletingPathExtension];
> NSString *tilePath = [basePath stringByAppendingPathExtension:@"SQL"];
> NSLog(@"Opening SQLite file %@", tilePath);
>
>     sqlite3 *db;
> int rc = sqlite3_open([tilePath cStringUsingEncoding:NSUTF8StringEncoding],
> &db);
> if (rc != SQLITE_OK) {
> NSLog(@"Can't open database: %s", sqlite3_errmsg(db));
> sqlite3_close(db);
> [self release];
> return nil;
> }
> self.db = db;
>
> [self createTablesIfNeeded];
>
>
> sqlite3_stmt *compiledStatement = NULL;
> rc = sqlite3_prepare_v2(db, "select max(thoroughness) from Table;", -1,
> &compiledStatement, NULL);
> rc = sqlite3_step(compiledStatement);
> self.levelsOfThoroughness = sqlite3_column_int(compiledStatement, 0);
>
> NSLog(@"This file has %d levels of thoroughness",
> self.levelsOfThoroughness);
> }
> return self;
> }
>
> In there you can see:
> - how to open a database
> - how to close a database
> - how to execute a SQL statement
> - how to check for error
>
> Which should be a good start.
>
> Jean-Denis Muys
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 



Thanks & Regards

Irfan Khan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to