mardi 5 mai 2015

executenonquery not working, no collumns edited

I am trying to update my database. However when I print object that gets returned by ExecuteNonQuery() it says 0. I think it's because of my where clause, because when I add this clause to a select query, it stops working too. I just can't find what's wrong with it.

Here's my code:

try
        {
            using(dbConnection = new SqliteConnection(dbConnString))
            {
                dbConnection.Open();
                using(dbCommand = dbConnection.CreateCommand())
                {
                    dbCommand.CommandText = "UPDATE 'GameObject' SET 'LocationX' = @locX, 'LocationY' = @locY, 'LocationZ' = @locZ WHERE 'id' = @id";
                    dbCommand.Parameters.AddRange(new SqliteParameter[]
                    {
                        new SqliteParameter("@locX") { Value = x},
                        new SqliteParameter("@locY") { Value = y},
                        new SqliteParameter("@locZ") { Value = z},
                        new SqliteParameter("@id") {Value = id}

                    });
                    int i = dbCommand.ExecuteNonQuery();
                    Debug.Log(i);
                }//end dbcommand
            }//end dbconnection
        }//end try
        catch(Exception e)
        {
            Debug.Log(e);
        }

Aucun commentaire:

Enregistrer un commentaire