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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:50:19+00:00 2026-05-25T19:50:19+00:00

I am using this code to insert the data in my database but it

  • 0

I am using this code to insert the data in my database

but it is not working..

My data is not being inserted in the table ..

what can be the problem??

in function.h

 +(BOOL)insertStudentinfoData:(NSString *)first_name last_name:(NSString *)last_name phone_num:(NSString *)phone_num;

in function.m

 +(BOOL)insertStudentinfoData:(NSString *)first_name last_name:(NSString *)last_name phone_num:(NSString *)phone_num
  {
    NSString *sql = [NSString stringWithFormat:@"insert into add_data   
    values(NULL,'%@','%@','%@')",first_name,last_name,phone_num];
    return [DBOperation executeSQL:sql];
 }

And I am giving the data from this

[Function insertStudentinfoData:@"hello" last_name:@"w3qrq" phone_num:@"efew"];

but my data is not being inserted in the table

////In DBOperation.h

    +(BOOL) executeSQL:(NSString *)sqlTmp {

if(conn == SQLITE_OK) {
    NSLog(@"\n\n%@",sqlTmp);       

    const char *sqlStmt = [sqlTmp cStringUsingEncoding:NSUTF8StringEncoding];
    sqlite3_stmt *cmp_sqlStmt1;
    int returnValue = sqlite3_prepare_v2(database, sqlStmt, -1, &cmp_sqlStmt1, NULL);

    returnValue == SQLITE_OK ?  NSLog(@"\n Inserted \n") :NSLog(@"\n Not Inserted \n");

    sqlite3_step(cmp_sqlStmt1);
    sqlite3_finalize(cmp_sqlStmt1);

    if (returnValue == SQLITE_OK) {
        return TRUE;
    }
}
return FALSE;

}

  • 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-25T19:50:20+00:00Added an answer on May 25, 2026 at 7:50 pm

    I guess you are passing the NULL value for PRIMARY KEY, first reset the simulator

    if you are not specifying the column name and inserting the values then you should pass the value for each column in particular order of column created otherwise its a good idea to specify column

    NSString *sql = [NSString stringWithFormat:@"INSERT INTO add_data 
                         (first_name,last_name,phone_num) VALUE('%@','%@','%@')",first_name,last_name,phone_num];
    

    or

    NSString *sql =[NSString stringWithFormat:@"INSERT INTO add_data 
    (first_name,last_name,phone_num,email,address,city,zip) VALUES 
    ('%@','%@','%@','%@','%@','%@','%@');",first_name,last_name,phone_num,email,addr‌​ess,city,zip];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to delete a row in a table, but it's not
SQLite insert statement does not insert the new data i am using this code
I'm trying to insert registration data into a database but my php code isn't
I'm using this code to reset the identity on a table: DBCC CHECKIDENT('TableName', RESEED,
I am using QSqlQuery to insert data into a MySQL database. Currently all I
Because of legacy data which is not available in the database but some external
This stored procedure does not save the data, it seems to be a problem
I have the following code that creates my table. I insert data into it
i am trying to insert data to database but it removing braces'{}' while inserting
I want to create database and enter data .But i do not want to

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.