I'm trying to use SQLite integration with Unity3D, like in somes tutorials. But i'm having a problem..
This is my create table:
public void CreateTablePaciente ()
{
string sqlCreatePacientes;
DbConnection connection = new SqliteConnection(urlDataBase);
IDbCommand command = connection.CreateCommand();
connection.Open();
sqlCreatePacientes = "CREATE TABLE IF NOT EXISTS " + tabela
+ " (cpf TEXT PRIMARY KEY, "
+ "nome TEXT NOT NULL, "
+ "sexo TEXT NOT NULL, "
+ "endereco TEXT NOT NULL, "
+ "email TEXT, "
+ "dataNascimento TEXT NOT NULL, "
+ "telefone TEXT NOT NULL, "
+ "numeroConsultas TEXT NOT NULL"
+ ");";
command.CommandText = sqlCreatePacientes;
command.ExecuteNonQuery ();
}
And this is my Insert method:
public void InsertPaciente (Paciente paciente)
{
string sqlInsert;
DbConnection connection = new SqliteConnection(urlDataBase);
IDbCommand command = connection.CreateCommand();
sqlInsert = "INSERT INTO " + tabela
+ " (cpf, nome, sexo, endereco, email, dataNascimento, telefone, numeroConsultas)"
+ " VALUES ("
+ paciente.Cpf + ", "
+ paciente.Nome + ", "
+ paciente.Sexo + ", "
+ paciente.Endereco + ", "
+ paciente.Email + ", "
+ paciente.DataNascimento + ", "
+ paciente.Telefone + ", "
+ paciente.NumeroConsultas
+ ");";
connection.Open();
command.CommandText = sqlInsert;
Debug.Log (sqlInsert);
command.ExecuteNonQuery();
}
Insert Query:
INSERT INTO paciente (cpf, nome, sexo, endereco, email, dataNascimento, telefone, numeroConsultas) VALUES (00000000000, Nome 0, m, rua aposkpaosk0, aosais@asiapos.xpco0, 0/00/00, 00000000000, 0);
But i'm having this SQLite error..
SqliteSyntaxException: near "0": syntax error
Mono.Data.SqliteClient.SqliteCommand.GetNextStatement (IntPtr pzStart, System.IntPtr& pzTail, System.IntPtr& pStmt)
Mono.Data.SqliteClient.SqliteCommand.ExecuteReader (CommandBehavior behavior, Boolean want_results, System.Int32& rows_affected)
Mono.Data.SqliteClient.SqliteCommand.ExecuteNonQuery ()
PacienteDAO.InsertPaciente (.Paciente paciente) (at Assets/C#Script/PacienteDAO.cs:73)
Seems to be alright with the create table, but i don't know what this "near: '0'" means.. How i can fix it?