When performing the following UPDATE
through my API (.NET Core):
UPDATE Aula
SET WHATEVER = WHATEVER
WHERE ID_AULA = @examID
Code:
string query = builder
.AppendLine("UPDATE Aula")
.AppendLine("SET WHATEVER = WHATEVER")
.AppendLine("WHERE ID_AULA = @examID").ToString();
SqlCommand command = new SqlCommand(query, sqlConnection);
command.Parameters.AddWithValue("@examID", item.ExamID);
sqlConnection.Open();
command.ExecuteNonQuery();
I get the following error: Conversion failed when converting the varchar value '22234390|22234391' to data type int.
Since my ID_AULA
field is a varchar
field and the @examID
parameter comes from a string
property.
If I do the same operation by the bank in this way, it works:
UPDATE Aula
SET WHATEVER = WHATEVER
WHERE ID_AULA = '22245089|22245090'
Why does this happen and how do I fix it?