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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:14:41+00:00 2026-05-31T05:14:41+00:00

– (UserInfo*)getCurrentUserInfo:(NSString*)userName { UserInfo *userInfo = [[UserInfo alloc]init]; sqlite3 *database; sqlite3_stmt *selectstmt; NSLog(@userName:%@,userName); if(sqlite3_open([databasePath

  • 0
- (UserInfo*)getCurrentUserInfo:(NSString*)userName
{
    UserInfo *userInfo = [[UserInfo alloc]init];

    sqlite3 *database;
    sqlite3_stmt *selectstmt;
    NSLog(@"userName:%@",userName);
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        NSString *sqlString = [NSString stringWithFormat:@"SELECT USER_LEVEL FROM USER_INFO WHERE USER_NAME = '%@'" , userName];
        NSLog(@"getCurrentUserInfo:%@",sqlString);
        const char *SqlCommand = [sqlString UTF8String];
        if (sqlite3_prepare_v2(database, SqlCommand, -1, &selectstmt, NULL) == SQLITE_OK) {
            NSLog(@"success!");
            while (sqlite3_step(selectstmt) == SQLITE_ROW) {
                NSString *userInfoStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
                NSLog(@"select result:%@",userInfoStr);
            }
        }
        sqlite3_finalize(selectstmt);
    }
    sqlite3_close (database);
    return userInfo;
}

the following is my log output:

2012-03-06 17:50:11.556 MagicWords[508:f803] userName:Tan
2012-03-06 17:50:11.557 MagicWords[508:f803] getCurrentUserInfo:SELECT USER_LEVEL FROM USER_INFO WHERE USER_NAME = 'Tan'

It doesn’t print “success”,so sqlite3_prepare_v2 don’t return yes.but my database is ok:

I can’t find the problem?

  • 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-31T05:14:42+00:00Added an answer on May 31, 2026 at 5:14 am

    Add sqlite error message . It will give an insight of what is going on inside. If all about your database is correct ,check the table name.

    UserInfo *userInfo = [[UserInfo alloc]init];
    
        sqlite3 *database;
        sqlite3_stmt *selectstmt;
        NSLog(@"userName:%@",userName);
        if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
            NSString *sqlString = [NSString stringWithFormat:@"SELECT USER_LEVEL FROM USER_INFO WHERE USER_NAME = '%@'" , userName];
            NSLog(@"getCurrentUserInfo:%@",sqlString);
            const char *SqlCommand = [sqlString UTF8String];
            if (sqlite3_prepare_v2(database, SqlCommand, -1, &selectstmt, NULL) == SQLITE_OK) {
                NSLog(@"success!");
                while (sqlite3_step(selectstmt) == SQLITE_ROW) {
                    NSString *userInfoStr = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
                    NSLog(@"select result:%@",userInfoStr);
                }
            }
          //Add the error message here.
           else
            {
    
             NSLog(@"%s",sqlite3_errmsg(database));
    
            }
           ///////
            sqlite3_finalize(selectstmt);
        }
        sqlite3_close (database);
        return userInfo;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My NSXMLParser breaks on this string: <title>AAA &#8211; BCDEFGQWERTYUIO</title> I parsed it in this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am getting notice on line 30 that twetout is undefined variable <?php $username
Have a webpage that will be viewed by mainly IE users, so CSS3 is
I would like to count the length of a string with PHP. The string
I've got the following login script.. <?php $name = $_POST[name]; $password = $_POST[password]; $query
So to start, I have an array of XML files. These files need to
I'm struggling to position the second level of a dropdown nav menu and was
I'm trying to craft a Java regular expression to split strings of the general
Welcome to Spring Roo. For assistance press CTRL+SPACE or type hint then hit ENTER.

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.