>

Fórum

Fórum da RL System, voltado para analistas, programadores etc. Tudo sobre linguagem de programação e desenvolvimento Full Stack: Banco de Dados, Android, C#, Java, .NET, PHP, Node, Javascript, TypeScript, Front, HTML e muito mais.



Banco de dados SQLITE. xcode Version 6.4 (6E35b)


Boa noite!
Nao consigo criar o banco, mesmo com o site do Klebermota.eti.br...
Minha versao do xcode é 6.4, pode me ajudar?
Nao aparece a mensagem de sucesso no console e nem no terminal...




#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

NSArray *diretorioPaths;
NSString * dir;

diretorioPaths = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);

dir = [diretorioPaths objectAtIndex:0];


// Mostra onde o banco é criado no sqlite3
//NSLog(@"%@",dir);

_databasePath = [[NSString alloc] initWithString:[dir stringByAppendingPathComponent:@"provas.db"]];

//int sqlite3_open( const char *db, sqlite3 **databasePath);


NSFileManager *file = [NSFileManager defaultManager];

if ([file fileExistsAtPath: _databasePath] == NO) {

const char *dbPath = [_databasePath UTF8String];

if (sqlite3_open(dbPath, &_db) == SQLITE_OK) {
char *error_msg;

const char *sql_stm = "create table is not exists clients ( id integer primary key autoincrement, nome text, email text)";


//create table contacts (id integer primary key autoincrement, nome text, email text);



if (sqlite3_exec(_db, sql_stm, NULL,NULL, &error_msg) == SQLITE_OK) {

NSLog(@"Sucesso!");

}else {
NSLog(@"Erro");

}

sqlite3_close(_db);
}

}
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end



2 Respostas


Ola Cristiano

mostra o NSLog(@"Erro");

????




tente colocar ao inves de

create table is not exists clients

coloque assim

create table if not exists clients