0

I am using this query to populate and create my table.But Its not creating the table and not inserting values.Using FMDB for ios.I am a noob in ios database and this is not working.Please guide me how should I make it work.Thanks in Advance.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *docsPath = [paths objectAtIndex:0];
 NSString *path = [docsPath stringByAppendingPathComponent:@"example.db"];

  database = [FMDatabase databaseWithPath:path];

 [database open];

 [database executeUpdate:@"CREATE TABLE `report` (`id` int(100) NOT NULL AUTO_INCREMENT,`Date` double NOT NULL,`product` varchar(200) NOT NULL,`Description` varchar(200) NOT NULL,`price` varchar(200) NOT NULL,`address` varchar(200) NOT NULL,`payment` varchar(200) NOT NULL, PRIMARY KEY (`id`))"];


 [database executeUpdate:@"insert into report(Date, product, Description, price, address,payment) values(?,?,?,?,?,?)",
 1/1/05,abc,example,example123,example456,123,nil];
Jacob Wood
  • 467
  • 9
  • 26

1 Answers1

2

It`s a SQLite , not MySQL

use this query to create table if it does not exist

CREATE  TABLE  IF NOT EXISTS report (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , date DOUBLE NOT NULL , product VARCHAR NOT NULL , description VARCHAR NOT NULL , price VARCHAR NOT NULL , address VARCHAR NOT NULL , payment VARCHAR NOT NULL )
ogres
  • 3,660
  • 1
  • 17
  • 16