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 6469677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:01:17+00:00 2026-05-25T06:01:17+00:00

I’m dealing here with a new problem. I started with the following code: -(IBAction)

  • 0

I’m dealing here with a new problem.
I started with the following code:

-(IBAction) Login:(id) sender{

    const char *dbpath = [databasePath UTF8String];
    sqlite3_stmt *statement;

    if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
    {
        NSString *querySQL = [NSString stringWithFormat: @"SELECT * FROM Contacts WHERE Login= (\"%@\") AND Password = (\"%@\")", Login.text, Password.text];

        const char *query_stmt = [querySQL UTF8String];

        if (sqlite3_prepare_v2(contactDB, query_stmt, -1, &statement, NULL) == SQLITE_OK)
        {
            if (sqlite3_step(statement) == SQLITE_ROW)
            {
                //Store '1' when a user wants to stay logged 
                **if(logSwitch.on){
                    [self aStayLogged];
                }else{
                    [self aReleaseLogged];
                }**
                Model *model = [Model sharedModel];
                model.paramLogged = Login.text;
                //[self openSecondView:nil];

            } else {
                Status.text = @"Login failed: Please check your ID and Password";
            }

            sqlite3_finalize(statement);
        }
        sqlite3_close(contactDB);
    }
}

-(void) aStayLogged {

    sqlite3_stmt *statement;

    const char *dbpath = [databasePath UTF8String];

    if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
    {
            NSString *updateSQL = [NSString stringWithFormat: @"UPDATE CONTACTS SET LOGGED = '1' WHERE LOGIN = (\"%@\")", Login.text];     
            const char *update_stmt = [updateSQL UTF8String];      
            sqlite3_prepare_v2(contactDB, update_stmt, -1, &statement, NULL);

        int success = sqlite3_step(statement);
            if (success == SQLITE_ERROR) {
                //NSAssert1(0, @"Error: failed to insert into the database with message '%s'.", sqlite3_errmsg(contactDB));
                Status.text = @"Update failed";
            }else{
                **Status.text = @"Stay OK";**
            }
        //sqlite3_bind_text(statement, 1, [coffeeName UTF8String], -1, SQLITE_TRANSIENT);
        //sqlite3_bind_int(statement, 2, coffeeID);

        sqlite3_finalize(statement);
    }
    sqlite3_close(contactDB);
}

Here’s the deal: If I link the method ‘aStayLogged’ as an IBAction to a button, the update is done correctly. But when I embed this method into the ‘Login’ method, nothing happens!

I check this with the method:

-(IBAction) Check{

    sqlite3_stmt *statement;

    const char *dbpath = [databasePath UTF8String];

    if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
    {
        NSString *querySQL = [NSString stringWithFormat: @"SELECT LOGIN FROM CONTACTS WHERE LOGGED = '1'"]; 
        const char *query_stmt = [querySQL UTF8String];

        sqlite3_prepare_v2(contactDB, query_stmt, -1, &statement, NULL);

        if (sqlite3_step(statement) == SQLITE_ROW) {

            NSString *loggedField = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 0)];

            Status.text = loggedField;

            [loggedField release];

        }else{

            Status.text = @"Update failed";

        }

        sqlite3_finalize(statement);
    }
    sqlite3_close(contactDB);    

}

The funny thing is that the status changes into “Stay OK” which is a confirmation that it should have worked! Does anyone have an idea what could be the cause of this? Sorry for the long post – I also happen to ask stupid questions, but this time I really don’t see it…

  • 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-25T06:01:18+00:00Added an answer on May 25, 2026 at 6:01 am

    Hm, I think what you used wrong to check with SQLITE_ERROR, because there are many other status code which mate not complete, you better to check on SQLITE_OK or SQLITE_ROW, and if you got this status code, than you’re done well.

    If you got an error, than use sqlite3_errmsg to find out what went wrong. I think there is something with SQLITE_BUSY perhaps or LOCK

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.