SQlite Detects me 0 as null

2

I have to insert a record at run time where one of the parameters is 0;

        using (SQLiteConnection conexion = new SQLiteConnection(conectionString))
        {
            //Inserta Investigacion1
            SQLiteCommand investigacion1 = new SQLiteCommand();
            investigacion1.CommandText = @"INSERT INTO Investigacion_Partida (idPartida, idInvestigacion, nivel) VALUES (@idPartida,@idInvestigacion,@nivel)";
            investigacion1.Connection = conexion;
            investigacion1.Parameters.Add(new SQLiteParameter("@idPartida", idPartida));
            investigacion1.Parameters.Add(new SQLiteParameter("@idInvestigacion", 1));
            investigacion1.Parameters.Add(new SQLiteParameter("@nivel", 0));
            conexion.Open();
            investigacion1.ExecuteNonQuery();
            conexion.Close();
        }

The problem is that this 0 detects it as a null and it's funny because if I put the same instruction in Query if you enter the 0 and insert it perfectly. (If I change the 0 for a one for example, it also inserts it well )

insert into Investigacion_Partida values(1,1,0);

This does work and I think it's exactly the same thing I want to say in c #.

    
asked by Hector Lopez 01.03.2018 в 10:11
source

1 answer

0

I just fixed it, putting;

 int cero = 0
 investigacion1.Parameters.Add(new SQLiteParameter("@nivel",cero));

I do not pass the value directly, it is defined in a variable. There are some things that are incomprehensible ... hahaha

    
answered by 01.03.2018 в 11:32