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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:59:55+00:00 2026-05-28T07:59:55+00:00

I have created one application, where I am storing the data into database and

  • 0

I have created one application, where I am storing the data into database and reading it. I have created a .sql file and added it into the resource folder. I can save and retrive the data over the simulator, my app is working fine over simulator but when I install the same app over device I am getting error as “no such table”.

Can anyone provide solution over this issue.

Here is the block of code that i m using:

/////// Inside AppDelegate.m >>Start>>>

///// to check the database exist or not >>>>

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;

NSString *dbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"TempDatabase.sql"];
BOOL success = [fileManager fileExistsAtPath:dbPath]; 

if(!success) {

    NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"TempDatabase.sql"];
    success = [fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];


    if (!success) 

        NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);  

} else {

    NSLog(@"Database file found at path %@", dbPath);

}

/////// Inside AppDelegate.m <<

/////// Logic to write files in database >>> start>>

           sqlite3 *pDb; 
    char *databaseName; 

    databaseName = @"TempDatabase.sql";

    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDir = [documentPaths objectAtIndex:0];
    //databasePath = [documentsDir stringByAppendingPathComponent:databaseName];

    databasePath =[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"TempDatabase.sql"];

    //[self copyDatabaseIfNeeded];


    if(sqlite3_open([databasePath UTF8String], &pDb) == SQLITE_OK) 
    {

        const char *sqlStatement = "INSERT INTO tablename (name) VALUES(?)";

        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(pDb, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
        {


             sqlite3_bind_text( compiledStatement, 1, [strTxtFldValue UTF8String], -1, SQLITE_TRANSIENT);
        }
        if(sqlite3_step(compiledStatement) != SQLITE_DONE ) 
        {
             NSLog( @"~~~~~~~~~~~ 1 Error: %s", sqlite3_errmsg(pDb) );
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Name name is not added." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];

        } else {

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirmation" message:@"name is added successfully." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];

                }
        sqlite3_finalize(compiledStatement);
    }

    sqlite3_close(pDb);

/////// Logic to write files in database <<

  • 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-28T07:59:55+00:00Added an answer on May 28, 2026 at 7:59 am

    Have you tried by creating database at runtime. Execute the query at runtime and create the table, try this out this will definitely help you out.

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

Sidebar

Related Questions

I have created one user named tuser with create database rights in SQL server
I have created one application in flex that is accessing the Java webservice using
hello i have created one windows application in c# .net and its working fine
I have created two forms in my Windows Application. One Form acts as a
I have created two JavaScript files. One file is "validators.js" and the other is
Im using c# .net windows form application. I have created a database which has
I have a large amount of data i want to import into one sqlite
I have an application that will, among other things, store various data into a
I have two windows application, one is a windows service which create EventWaitHandle and
I have created one table using the below command: create table Table1( Id int

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.