Friday, 26 April 2013

Hello all,
Here i have just share you the simple steps.

First download the database supported files from this  or this URL,

1) VIDatabase.h
2) VIDatabase.m
3) VIdbConfig.h
4) VIResultSet.h
5) VIResultSet.m

Download these files from above links and add in your project.

and how to use it,

1) Import  "VIdbConfig.h" in your project Delegate

And put this code in your Delegate.m file

 db = [VIDatabase databaseWithName:kDBName]; // See below note.
if (![db open]) {
NSLog(@"Could not open db.");
}else {
NSLog(@"Open db.");
}

NOTE:- kDBName is define in VIdbConfig.h so Please change the Database name in VIdbConfig.h in 10th line give your own database name like // #define kDBName @"DB.sqlite"

2) for fetching the data.

      First Import    #import "VIdbConfig.h"

    NSString *strSelect = [NSString stringWithFormat:@"select *  from tblname"];
    rs = [db executeQuery:strSelect];

3) for Execute other Queries for insert / update / delete

      First Import    #import "VIdbConfig.h"

        NSString *strInsert = [NSString stringWithFormat:@"insert into tblname (Title,AddDate,RemDate)values('%@','%@','%@')",txtTitle.text,dateString,txtDate.text];
        [db executeUpdate:strInsert];

            NSString *strDelete = [NSString stringWithFormat:@"delete from tblname where ID = '%@'",[[arrData objectAtIndex:index]valueForKey:@"ID"]];
            [db executeUpdate:strDelete];


Thanks and Good luck,