How to view sqlite database by button press

hye all, i have built a SQLite database and wanna to add into iphone app. already i have add it resource->add->x.sqlite and also add libsqlite3.0.dylib.framework but i don't know what is the showing code. I wanna to show the data in the db when user pressed button. Can anyone help me to give an example on how the db can be view when button is press??

Answers


Here's some basic code to query the database:

-(NSArray*)names
{
    NSString* query = [[NSString alloc] initWithString:@"SELECT name FROM sometablename;"];
    sqlite3_stmt* statement;

    int retval = sqlite3_prepare_v2(yourDatabaseHandle, [query UTF8String], -1, &statement, nil);
    [query release];
    if (retval != SQLITE_OK)
    {
        sqlite3_close(yourDatabaseHandle);
        NSAssert1(0, @"Error querying table: %i", (retval ^ SQLITE_ERROR));
        return nil;
    }

    NSMutableArray* values = [[[NSMutableArray alloc] init] autorelease];
    while (sqlite3_step(statement) == SQLITE_ROW)
    {
        const char* value = (const char*)sqlite3_column_text(statement, 0);
        NSString* s = [[NSString alloc] initWithUTF8String:value];
        [values addObject:s];
        [s release];
    }

    sqlite3_finalize(statement);

    return values;
}

You might want to present this in a table view. There are plenty of questions & answers here on Stack Overflow already to explain how to do that, as well as plenty of Apple sample code.


Need Your Help

Redirecting to force usage of www and SSL for domain in Plesk

ssl rewrite plesk

I have been using this in order to force usage of HTTPS:

Browser F11 Fullscreen Does Not Register with -webkit-full-screen or Javascript API

javascript css html5

I am using javascript(for example, requestFullscreen) and css(:-webkit-full-screen) API's to detect the browser's state in full screen or not. I don't have a issue with these API's, as they work