Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 758331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:28:01+00:00 2026-05-14T15:28:01+00:00

-(IBAction)ButtonPressed:(id)sender { const char *sql = SELECT AccessCode FROM UserAccess; NSString *sqlns; sqlns =

  • 0
  -(IBAction)ButtonPressed:(id)sender
    { 
        const char *sql = "SELECT AccessCode FROM UserAccess";
        NSString *sqlns;
        sqlns = [NSString stringWithUTF8String:sql];
        if([Password.text isEqual:sqlns])
        {
            NSLog(@"Correct");
        }
            else {
                NSLog(@"Wrong");
            }

    NSLog(@"%@",sqlns);
    }

Noob here ,
At NSLog I am able to print “SELECT AccessCode FROM UserAccess” where as let say the access code is 1234 , which I want .The challenge is to execute the command so that I can retrieve
1234 from the Column AccessCode in the Table UserAccess in the datable UserAcess.sqlite
My Database and table name are same oops .
In the appdelegate I Have :
///

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after app launch 
    [self createEditableCopyOfDatabaseIfNeeded];    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

    return YES;
}

///

 - (void)createEditableCopyOfDatabaseIfNeeded {

        NSLog(@"Creating editable copy of database");

        // First, test for existence.

        BOOL success;

        NSFileManager *fileManager = [NSFileManager defaultManager];

        NSError *error;

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

        NSString *documentsDirectory = [paths objectAtIndex:0];

        NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"UserAccess.sqlite"];

        success = [fileManager fileExistsAtPath:writableDBPath];

        if (success) return;

        // The writable database does not exist, so copy the default to the appropriate location.

        NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"UserAccess.sqlite"];

        success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];

        if (!success) {

            NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);

        }

    }

///

+(sqlite3 *) getNewDBConnection{

    sqlite3 *newDBconnection;

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"UserAccess.sqlite"];

    // Open the database. The database was prepared outside the application.

    if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK) {

        NSLog(@"Database Successfully Opened :) ");

    } else {

        NSLog(@"Error in opening database :( ");

              }

              return newDBconnection;

              }

Please help 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:28:01+00:00Added an answer on May 14, 2026 at 3:28 pm

    You need to make some sqlite3 calls to execute the select statement and retrieve the column values.

    The sqlite3 quick start has everything in it you need to know for this particular task.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

-(IBAction)EnterButtonPressed:(id)sender { const char *sql = SELECT AccessCode FROM UserAccess; double result = ([Password.text
- (IBAction)EnterButtonPressed:(id)sender { Sqlite *sqlite = [[Sqlite alloc] init]; NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString
Some simple code: - (IBAction)Up_Down:(UIStepper *)sender { double value = [sender value]; [NumDayLabel setText:[NSString
I have the following piece of code - (IBAction)buttonPressed: (id) sender { UIButton *button
- (IBAction)buttonPressed:(id)sender { UIDevice *device = [UIDevice currentDevice]; device.batteryMonitoringEnabled = YES; if ([[UIDevice currentDevice]
I am a N00b here . I print my currency like this : -(IBAction)buttonPressed1:(id)sender
- (IBAction)onClick1:(id)sender { // Make sure it's a UIButton if (![sender isKindOfClass:[UIButton class]]) return;
-(IBAction)registerUpdate:(id)sender { HTTPRequest* request = [[HTTPRequest alloc] initWithUrl:@http://www.yahoo.com delegate:self]; [request doRequest]; } The HTTPRequest
-(IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@myaudiofile ofType:@caf]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL
-(IBAction)flipView:(id)sender { MapController *nextVC = [[MapController alloc] initWithNibName:@MapController bundle:nil]; nextVC.title = @Map; nextVC.longi =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.