mardi 20 janvier 2015

Append String and Variable to SQLite Column

I am trying to append a string value and a variable to a column in my database. Currently I have the following:



using (SQLiteCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "UPDATE Movies SET part = part || @part WHERE id = @id";
cmd.Parameters.Add(new SQLiteParameter("@part", part));
cmd.Parameters.Add(new SQLiteParameter("@id", id));
conn.Open();
}


However, I would like to add a : delimiter between the old and new values.


Eg: The current value of the column part is 1. The value I want to append is 2. So the final result in the column should be 1:2.


I have tried:



cmd.CommandText = "UPDATE Movies SET part = part || ':' + @part WHERE id = @id";


But this seems to add 1 and 2 together.


Would anyone know the correct syntax for this?


Aucun commentaire:

Enregistrer un commentaire