objective c - select data record in table sqlite ios return with only one object -


"itemprop =" text ">

I have a problem when I return the selected username to include only one object and all of the table username that is how I solved this we have to try to select the database manager and find that I query SQL statement is correct

  - (NSMutableArray *) FindAccounts {/// database NSString * docsDir; NSArray * Direpath; // Documents Directory dirPaths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes) Go; Doxdir = [डायपरपेट ऑब्जेक्टऐंडएक्स: 0]; // Create database path of the database file DatabasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @ "TRIAL.sqlite"]]; NSFileManager * filemgr = [NSFileManager defaultManager]; Sqlite3_stmt * statement; Const char * dbpath = [databasePath UTF8String]; If (sqlite3_open (dbpath, & amp; contactDB) == SQLITE_OK) {NSString * querySQL = [NSString stringWithFormat: @ "USERNAME, select the type" CONTNEW]; Const char * query_stmt = [querySQL UTF 8 string]; NSMutableArray * resultArray = [[NSMUTABELARROL] INIT]; If (sqlite3_prepare_v2 (contactDB, query_stmt, -1, & amp; statements, zero) == SQLITE_OK) {if (sqlite3_step (statement) == SQLITE_ROW) {NSString * user = [[NSString alloc] initWithUTF8String: (const char *) Sqlite3_column_text (Statement, 0)]; [Results: Ore Object: Users]; Return result returned; } Else {NSLog (@ "not found"); Return zero; } Sqlite3_reset (statement); }} Return zero; }  "post-text" itemprop = "text"> 

OK, try it (note that there is not too much error reporting):

< p> / p>
  - (Nsmtablearray *) Findksounts {Nsstring * Dosdir = [Nssearchptfordirektorisindomans (Nsdokyumentdirectori, Nsusserdomanmsk, YES) Objektetindeks: 0]; NSString * DatabasePath = [DocsDir stringbappingingpacecompany: @ "Trial seallight"]; Sqlite3_stmt * statement; // Do I think that contact DB is a frequency variable? If (! Contact DB and Sclait 3_open ([Detabespath UTF-8 string], and contact DB)! = SQLITE_OK) {Anselog (fail open @ "database"); Return zero; } NSString * querySQL = @ "SELECT USERNAME, by user name contact type"; NSMutableArray * resultArray = [NSMutableArray new]; If (sqlite3_prepare_v2 (contactDB, [querySQL UTF8String], -1, & amp; statement, NULL) == SQLITE_OK) {while (sqlite3_step (statement) == SQLITE_ROW) {NSString * username = @ (sqlite3_column_text (Statement, 0)) ; [ResultsAre Object: Username]; } Sqlite3_reset (statement); } Return results; }  

Comments