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

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You don't have to add the + sign. opt <-… May 17, 2026 at 2:22 am
  • Editorial Team
    Editorial Team added an answer We have done this via using the "Authorization" header. The… May 17, 2026 at 2:22 am
  • Editorial Team
    Editorial Team added an answer Does this have the potential to silently break my code,… May 17, 2026 at 2:22 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the following piece of code - (IBAction)buttonPressed: (id) sender { UIButton *button
i have this: - (IBAction)checkupdate { statusText.text = [[NSString alloc] initWithFormat:@Checking......]; everytime i press
I'm loading two different views with this IBActions - (IBAction)showFirstView:(id)sender{ theDetailViewController = [DetailViewController new];
I am currently using this code to bring up an info window -(IBAction)showInfo:(id)sender {
I have a NSString member variable declared in the header file of the view
Here is the IBAction method linked to the UISwitch with the valueChanged event :
I have a viewController containing the following method: - (IBAction) playMovie { NSURL *url
I am trying to hook up a UIButton to a IBAction in interface builder
What is the purpose of using IBOutlets and IBActions in Xcode and Interface Builder?
I have a matrix of buttons, 4x3 And i have the following problems, or

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.