I have a SQL database being locally hosted that keeps track of stock, I'm trying to get the SQL command "UPDATE stock SET cantidad = 530 WHERE id = 0" through using a C# Windows form application. But I'm having no changes made on the codebase
For this, I've made a function "setCantidad", but it isn't working. I'm getting no errors, just no changes in the codebase. All the other functions, which are made similarly to this one, work well. The SQL command, when inputted directly into the codebase, works well.
Here's the function
public void setCantidad(int valorActualizado, int indice)
{
Conexion miConexion = new Conexion();
conectar = miConexion.GetConnection();
conectar.Open();
sql = "UPDATE stock " + "SET cantidad = " + valorActualizado + " WHERE id = " + indice;
MySqlCommand comando = new MySqlCommand(sql, conectar);
conectar.Close();
}
The value of the SQL variable is sql = UPDATE stock SET cantidad = 530 WHERE id = 0 once it reaches conectar.Close, so I doubt it's that.
MySqlCommand?comando.ExecuteNonQuery()is required before closing the connection.