Hello,
I am implementing Sqlite in my project i am using FMDB as a sqlite wrapper in my code. But whenever i insert the records i am getting the following error : DB Error: 1 "no such table: Tradeshow"
Here is the code :
Here have a look at my console screen
Here is the image of my Sqlite File its contains the tradeShow table
Here is the link of my Sample App : http://www.filefactory.com/file/ca6c8fc/n/Ipad_Test_2.zip
i dont know what the issue. Can any 1 point me where i am going wrong
I am implementing Sqlite in my project i am using FMDB as a sqlite wrapper in my code. But whenever i insert the records i am getting the following error : DB Error: 1 "no such table: Tradeshow"
Here is the code :
Code:
NSString *databaseName = [[NSString alloc] initWithString:@"iPad.sqlite"];
NSArray *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentsPath objectAtIndex:0];
NSString *databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL success = [fileManager fileExistsAtPath:databasePath];
if (!success) {
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databasePath];
[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}
[fileManager release];
db = [FMDatabase databaseWithPath:databasePath];
[db setLogsErrors:TRUE];
[db setTraceExecution:TRUE];
if (![db open]) {
NSLog(@"Failed To Open Database");
}
else
{
NSLog(@"Opened Database Successfully");
[db executeUpdate:@"insert into Tradeshow (TradeshowID, TradeshowName, TradeshowDescription, TradeshowPlace, TradeshowDate) values (?, ?, ?, ?, ?)" ,
[NSString stringWithFormat:@"number %d", 1],
[NSString stringWithFormat:@"number %d",2],
[NSString stringWithFormat:@"number %d",3],
[NSString stringWithFormat:@"number %d",4],
[NSString stringWithFormat:@"number %d",5] ];
FMResultSet *rs = [db executeQuery:@"select TradeshowID from Tradeshow"]; //where a = ?", @"safari's compass"];
while ([rs next]) {
int RecipeID = [rs intForColumn:@"TradeshowID"];
}
[rs close];
}
Here have a look at my console screen

Here is the image of my Sqlite File its contains the tradeShow table

Here is the link of my Sample App : http://www.filefactory.com/file/ca6c8fc/n/Ipad_Test_2.zip
i dont know what the issue. Can any 1 point me where i am going wrong
Last edited: