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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:44:27+00:00 2026-05-15T21:44:27+00:00

I have the following code: if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the

  • 0

I have the following code:

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) 
    {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement = "select ZWAYPOINT_X, ZWAYPOINT_Y from ZWAYPOINT where ZMAP_ID %@", mapID;
        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
        {
            // Loop through the results and add them to the Route Name array
            while(sqlite3_step(compiledStatement) == SQLITE_ROW) 
            {
                // Read the data from the result row
                if((char*)sqlite3_column_text(compiledStatement, 0) != NULL)
                {                                       
                    NSString *xCoordinate = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 0)];
                    NSString *yCoordinate = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 1)];

                    NSLog(@"xCoordinate: %@", xCoordinate);
                    NSLog(@"yCoordinate: %@", yCoordinate);

                    CLLocationCoordinate2D coordinate = {xCoordinate, yCoordinate};
                    MapPin *pin = [[MapPin alloc]initWithCoordinates:coordinate
                                                           placeName:@"Keenan Stadium"
                                                         description:@"Tar Heel Football"];
                    [self.mapView addAnnotation:pin];
                    [pin release];
                }
            }
        }
        else 
        {
            NSLog(@"Error: failed to select details from database with message '%s'.", sqlite3_errmsg(database));
        }

I have a few questions:

  1. in my SQL statement how do I include the variable mapID as part of the SQL statement
  2. the line

    CLLocationCoordinate2D coordinate = {xCoordinate, yCoordinate};

gives me the following warning “Incompatible types in initialization”

Thanks

  • 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-15T21:44:27+00:00Added an answer on May 15, 2026 at 9:44 pm

    You should use a parameterized statement and bind values, like this:

    const char *sqlStatement = "select ZWAYPOINT_X, ZWAYPOINT_Y from ZWAYPOINT where ZMAP_ID = ?";
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
    {
        sqlite3_bind_text( compiledStatement, 1, [mapID UTF8String], -1, SQLITE_TRANSIENT );
    

    (Note that when binding parameters, you start at 1, but when reading columns from result rows, you start at 0…). I’m assuming your mapID is an NSString since you tried to stick it in your query using %@. If it’s something else, you’ll have to use a different bind function and obviously skip the UTF8String.

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

Sidebar

Related Questions

I have the following statement in my code: if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) but
I have following code for inserting data into database using PDO. It inserts data
I'm trying to select data from the database and I have the following code
I use the following code to only read the database.... NSString *databasePath = [[[NSBundle
I have the following C code that uses sqlite3: if(SQLITE_OK == sqlite3_initialize()) { self->db_open_result
I have the following code for SQLite: std::vector<std::vector<std::string> > InternalDatabaseManager::query(std::string query) { sqlite3_stmt *statement;
I have the following code: import sqlite3 con = sqlite3.connect(testDB) cur = con.cursor() #cur.execute('CREATE
I have following code in initialization im = imread('Image02.tif'); figure(); imagesc(im); colormap(gray); [hImage hfig
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>
I have following code for updating user's column public void UpdateLastModifiedDate(string username) { 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.