Je le code suivant:Problème avec instruction SQL
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));
}
J'ai quelques questions:
- dans mon instruction SQL comment puis-je inclure les mapID variables dans le cadre de l'instruction SQL
la ligne
CLLocationCoordinate2D coordinate = {xCoordinate, yCoordinate};
me donne l'avertissement suivant "Types incompatibles dans l'initialisation"
Merci
Vous pouvez résoudre votre problème de déclaration SQL en passant à Core Data;) – jer
jer, assez drôle J'ai vu quelques personnes suggèrent cela lorsque des questions sur SQL sont postées. Je suis engagé maintenant si .... Je vais certainement revoir Core Data après avoir terminé cette application. Merci pour le conseil. – Stephen
Ce n'est pas une instruction SQL, c'est un code de procédure. – onedaywhen