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

  • Home
  • SEARCH
  • 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 6053743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:04:31+00:00 2026-05-23T08:04:31+00:00

I have an application in which I want to fetch content from a database

  • 0

I have an application in which I want to fetch content from a database using a particular ID column and later display all that content in textfields on a button press. The snippet below shows how I fetch the content in an array.

//this is a function which i am created which will be called in button click event  
-(NSArray*)getStudents 
{ 
    NSMutableArray *studentArray=[[NSMutableArray alloc]init]; 

    sqlite3_stmt *statement = nil; 
    NSString *query=@"select * from UserInformation where UserId=?"; 
    const char *sql = [query cStringUsingEncoding:NSUTF8StringEncoding]; 
    if (sqlite3_prepare_v2(dbConnection, sql, -1, &statement, NULL) == SQLITE_OK) { 
        while(sqlite3_step(statement) == SQLITE_ROW) { 
            Student *newStudent=[[Student alloc]init]; 
            newStudent.age=sqlite3_column_int(statement, 0); 
            newStudent.name=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)]; 
            [studentArray addObject:newStudent]; 
        } 
    } 

    return studentArray; 
}

I have a problem adding this array to my textfields so that when I click on the button my textfields are loaded with the values from the database for a particular userid. I have written the above function in one of my controllers and my textfields are defined in another controller. How do I fill the above array in my textfields?

  • 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-23T08:04:31+00:00Added an answer on May 23, 2026 at 8:04 am

    USe below as reference code ..

    //Get all your student object from database
    NSArray* myArray = [self getStudents ];
    //Use mutable string to append all the data in single string.
    NSMutableString* stringName = [NSMutableString stringWithString:@""];
    
    //Traverse through the Student array 
    for(id arrayObj in myArray)
    {
      Student* student = (Student*)arrayObj; 
      [stringName appendString:student.name];
      [stringName appendString:@" ";
    }
    
    //Now you have stringName variable holding all the student name and this is space      separated  string 
    myTextField.text = stringName;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented application in which i am using tabs and want to fetch
I have an application in which I want to authenticate a user from a
I have a backbone application which, upon load, needs to fetch data from four
i have developed an application in which i fetch books using googleapibook search. I
Suppose I have a application which fetch data from network and then showing those
I have an application with requests which fetch lists from huge tables (7 mil+
I have a Java application which I want to shutdown 'nicely' when the user
We have created an application which we want to run in a 64 bit
I have an application in which there is a form which I want to
I have an Excel application in which I want to present the user with

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.