Below is my code
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *dbPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [dbPath objectAtIndex:0];
NSString *writableDBPath= [documentsDir stringByAppendingPathComponent:@"mydb.sqlite"];
success = [fileManager fileExistsAtPath:writableDBPath];
if(success) return;
defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"mydb.sqlite"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success)
{
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
NSArray *dbPath=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
NSString *documentsDir = [dbPath objectAtIndex:0];
defaultDBPath = [documentsDir stringByAppendingPathComponent:@"mydb.sqlite"];
if (sqlite3_open([defaultDBPath UTF8String], &MyDB) == SQLITE_OK)
{
Mystmt==nil;
sqlite3_prepare_v2(MyDB, "SELECT name,address from doctor_tbl where name OR Location like \"?\" ", -1, &Mystmt, nil) ;
sqlite3_bind_text(Mystmt,1,[searchbartext UTF8String],-1,SQLITE_TRANSIENT);
while(sqlite3_step(Mystmt) == SQLITE_ROW)
{
//my column values
}
}
in the above code database is opened correctly and if i hardcode the values in query the query executes correctly but when i bind the text in query it is not working. there is no error in query i checked it.
Can any one help me. Thanks in advance