iphone - Retrieve detail of data on next view when a row is selected selected -
my next view has 4 fields, want show details when name selected on table.
code creating database as:
-(ibaction) savedata { sqlite3_stmt *statement; const char *dbpath = [databasepath utf8string]; if (sqlite3_open(dbpath, &information) == sqlite_ok) { nsstring *insertsql = [nsstring stringwithformat: @"insert contacts (name,address, phone,imageurl) values (\"%@\", \"%@\", \"%@\",\"%@\")", name.text,address.text,phone.text,imageurl.text]; const char *insert_stmt = [insertsql utf8string]; sqlite3_prepare_v2(information, insert_stmt, -1, &statement, null); if (sqlite3_step(statement) == sqlite_done) { status.text = @"contact added"; name.text = @""; address.text = @""; phone.text = @""; imageurl.text=@""; } else { status.text = @"failed add contact"; } sqlite3_finalize(statement); sqlite3_close(information); } }
i new ios development, please suggest how show data on detail view described above. thanks
for display data can try this
-(void)displaydata { const char *dbpath = [databasepath utf8string]; if(sqlite3_open(dbpath, &information)==sqlite_ok) { const char *qry=[@"select * contacts" utf8string]; sqlite3_stmt *statement; if (sqlite3_prepare_v2(dtdb, qry, -1, &statement, null)==sqlite_ok) { while (sqlite3_step(statement)==sqlite_row) { nsstring *name=[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 0)]; nsstring *address=[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 1)]; nsstring *phone=[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 2)]; nsstring *imageurl=[nsstring stringwithutf8string:(const char *)sqlite3_column_text(statement, 3)]; nslog(@"name:%@ , address :%@ , phone:%@ , imageurl:%@",name,address,phone,imageurl); } } } }
Comments
Post a Comment