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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:27:36+00:00 2026-06-05T05:27:36+00:00

I am deleting all data from the table by using below code snippet NSString

  • 0

I am deleting all data from the table by using below code snippet

NSString *deleteStatementNS = [NSString stringWithFormat:
                               @"DELETE FROM %@",[tableNames objectAtIndex:i]];

const char *prepareDelete ="DELETE FROM '?'";
const char *tbleName = [[tableNames objectAtIndex:i] UTF8String];
if (sqlite3_prepare_v2(dBase, prepareDelete, -1, &dbpreprdstmnt, NULL) == SQLITE_OK) 
{
    dbrc = sqlite3_bind_text(dbpreprdstmnt, 1, tbleName, -1, SQLITE_TRANSIENT);
    dbrc = sqlite3_step(dbpreprdstmnt);

    sqlite3_finalize(dbpreprdstmnt);
    dbpreprdstmnt = NULL;
} 
else 
{
    NSLog(@"Error %@",[NSString stringWithCString:sqlite3_errmsg(dBase) encoding:NSUTF8StringEncoding]);
}

But unfortunately the delete is not happening I am getting error as Error no such table: ?
I am not able to prepare the statement only. But if i use prepare statement like below

const char *prepareDelete =[deleteStatementNS UTF8String];

This is working absolutely fine. I am not able to bind the variable to stop SQL injection attacks.May I know the reason behind this error please. I found many places where this code snippet is reported as its is working fine.

  • 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-05T05:27:38+00:00Added an answer on June 5, 2026 at 5:27 am

    I am not able to bind the variable to stop SQL injection attacks.

    Table names cannot be bound as variables.

    To avoid SQL injection attacks don’t let your users specify which table names will be deleted. Make sure the table names come from a trusted source (e.g. hardcoded in your program).

    In fact it’s a really bad idea to delete all data in a table when the table name comes from an untrusted source. Even if you prevent SQL injection attacks, an attacker could still delete data you didn’t want them to delete.

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

Sidebar

Related Questions

Need help with deleting call log from multi numbers, using the following code i
Is there a query in SQL Server 2008 which will delete data from all
What is the need of Collection framework in Java since all the data operations(sorting/adding/deleting)
I am deleting an image file from my application. I was doing new File(filename).delete
I have problems with deleting a record from the screen using MSQLI. Here you
I'm trying to delete all entrys from my abstractTableModel. As long as I don't
I've just started using SQLite and I want to write all my application data
I am trying to using a SQL data reader to move records from one
In my app i have reset button which delete all the data of tables
I have a code that fetches a list from DB. Using that returned array

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.