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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:35:49+00:00 2026-06-16T03:35:49+00:00

I created a table using SQLite Manager(firefox plugin) with 4 columns and 5 rows.

  • 0

I created a table using SQLite Manager(firefox plugin) with 4 columns and 5 rows.
Now i wanted to fetch an entire random row from that table with help of following code but it doesnt works as i have never used it before.. what am i possibly doing wrong??

-(NSDictionary *)fetchQuestionsWithRowID:(NSInteger)rowID withDbPath:(NSString *)dbPath
        {

      NSDictionary *questDic=[NSDictionary dictionary];
            sqlite3 *database=nil;
            if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
            {
                const char *sql = "SELECT * FROM quizQuestions Where rowid=?";

                sqlite3_stmt *selectstmt;

                int result = sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL);

                if(result != SQLITE_OK) {
                    NSLog(@"Prepare-error #%i: %s", result, sqlite3_errmsg(database));
                }

                if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
                {
// confused here
                    sqlite3_bind_text16(selectstmt, 1, &rowID, -1, SQLITE_TRANSIENT);
                    while(sqlite3_step(selectstmt) == SQLITE_ROW) {

                        NSString *str = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];

                        NSLog(@"string is %@",str);

                    }
                }
            }
            sqlite3_close(database);
            return questDic;
        }
  • 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-06-16T03:35:50+00:00Added an answer on June 16, 2026 at 3:35 am

    Hemant, look at below code may be it help but you need to make that code according to your need, means need to correct table, etc:

     NSString* sqliteQuery = NULL;
        sqliteQuery = [NSString stringWithFormat:@"SELECT roomImage,bookID,roomName,floorID,roomDesc,id FROM roomTbl"];
        sqlite3_stmt* statement;
        if( sqlite3_prepare_v2(db, [sqliteQuery UTF8String], -1, &statement, NULL) == SQLITE_OK )
        {
            while( sqlite3_step(statement) == SQLITE_ROW )
            {
                NSMutableDictionary* dict = [NSMutableDictionary new];
                NSData* data = nil;
                int length = sqlite3_column_bytes(statement, 0);
                data       = [NSData dataWithBytes:sqlite3_column_blob(statement, 0) length:length];
                [dict setObject:[Base64 encode:data] forKey:@"imageFloorBytes"];
                int idFR = sqlite3_column_int(statement, 1);
                [dict setObject:[NSString stringWithFormat:@"%d",idFR] forKey:@"BookingID"];
    
                [dict setObject:[NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(statement, 2)] forKey:@"roomName"];
                [dict setObject:[NSString stringWithFormat:@"%d",sqlite3_column_int(statement, 3)] forKey:@"floorID"];
                [dict setObject:[NSString stringWithFormat:@"%s",(const char*)sqlite3_column_text(statement, 4)] forKey:@"roomDesc"];
                [dict setObject:[NSString stringWithFormat:@"%d",sqlite3_column_int(statement, 5)] forKey:@"roomID"];
                [arr addObject:dict];
                [dict release];
            }
        }
        // Finalize and close database.
        sqlite3_finalize(statement);
    

    Also, have you import your db? And, one more thing before doing any operation you must go for checking that the following file or db exists or not.

    Hope, it’ll sort-out your problem

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

Sidebar

Related Questions

I have created a data base (.sqlite) using SQLiteManager plugin for firefox,now I want
I'm a LaTeX beginner. Up until now whenever I've created a table (using the
I'm trying to follow http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/ And have created a very simple example http://jsfiddle.net/6wbZQ/ It's
i created a table with 7 columns and one row.but i cant able retrieve
I created a table in Sqlite by using the CREATE TABLE AS syntax to
I have successfully created a table using SQlite in android. There is a column
I'm trying to verify a table gets created. I'm using SQLite and NHibernate. new
I have created an sqlite table using the following statement: CREATE TABLE IF NOT
I have created one table using the below command: create table Table1( Id int
I have a table created in sql. but in my application I am using

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.