dimanche 15 février 2015

sqllite near : syntax error

i am b=newbie in sqllite database i make an app that contain sqllite database i created table and insert value in to table but when i fetch data from table then it give me error like as near "Dhanani": syntax error


Here my Fetch Data Method Like as



-(void)getTextFromDb
{
NSLog(@"Method Called");
NSString *docsDir;
NSArray *dirPaths;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];

_databasePath = [[NSString alloc]
initWithString: [docsDir stringByAppendingPathComponent:
@"QpinData.db"]];
const char *dbpath = [_databasePath UTF8String];
sqlite3_stmt *statement;
if (sqlite3_open(dbpath, &_myDatabase) == SQLITE_OK)
{
NSString *querySQL = [NSString stringWithFormat:@"SELECT QpinName,Address,Lat,Long,Type FROM QPINTABLE WHERE UserName=Ramesh Dhanani"];
const char *query_stmt = [querySQL UTF8String];

if (sqlite3_prepare_v2(_myDatabase, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
[self.qpinname removeAllObjects];
[self.qpinType removeAllObjects];
[self.address removeAllObjects];
[self.latitude removeAllObjects];
[self.longitude removeAllObjects];
while (sqlite3_step(statement) == SQLITE_ROW)
{
NSString *QpinName = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 0)];
NSString *Address = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 1)];
NSString *latitude = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 2)];
NSString *longitude = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 3)];
NSString *Type = [[NSString alloc] initWithUTF8String: (const char *) sqlite3_column_text(statement, 4)];
[self.qpinname addObject:[NSString stringWithFormat:@" %@ ", QpinName]];
[self.address addObject:[NSString stringWithFormat:@"%@ ",Address]];
NSLog(@"self.address %@",self.address);
[self.latitude addObject:[NSString stringWithFormat:@"%@",latitude]];
[self.latitude addObject:[NSString stringWithFormat:@" %@",longitude]];
[self.qpinType addObject:[NSString stringWithFormat:@" %@",Type]];
}
NSLog(@"%s",sqlite3_errmsg(_myDatabase));
sqlite3_finalize(statement);
}
NSLog(@"%s",sqlite3_errmsg(_myDatabase));
sqlite3_close(_myDatabase);
[self.personalTable reloadData];
}

}


and i insert value in to Table like asnear "Dhanani": syntax error. Please give me Solution for this.


Aucun commentaire:

Enregistrer un commentaire