Good will put my code here and have if someone can tell me what error I have here because I can not see it
public List<EntidadProducto> listarProductosCD(SqlConnection conexion, int ID, String nombre, decimal precio)
{
List<EntidadProducto> listaProductos = new List<EntidadProducto>();
CapaDProducto ocdProducto = new CapaDProducto();
using (conexion)
{
String consultaSqlUpdate = "UPDATE PRODUCTS SET ProductName=@ProductName, UnitPrice=@UnitPrice WHERE=" + ID;
SqlCommand comando = new SqlCommand(consultaSqlUpdate, conexion);
comando.Parameters.AddWithValue("@ProductName", nombre);
comando.Parameters.AddWithValue("@UnitPrice", precio);
int filaAfectados = comando.ExecuteNonQuery();
String consultaSql = "SELECT * FROM PRODUCTS";
SqlCommand comando2 = new SqlCommand(consultaSql, conexion);
SqlDataReader lectura = comando2.ExecuteReader();
while (lectura.Read())
{
EntidadProducto oentProducto = new EntidadProducto();
oentProducto.idProducto = lectura.GetInt32(lectura.GetOrdinal("ProductID"));
oentProducto.Nombre = lectura.GetString(lectura.GetOrdinal("ProductName"));
oentProducto.Precio = lectura.GetDecimal(lectura.GetOrdinal("UnitPrice"));
listaProductos.Add(oentProducto);
}
lectura.Close();
}
return listaProductos;
}
In the line int filaAfetados I get the following:
Am I storing the result in an integer variable because it gives me syntax error in the "="? Saying that I am new to ASP.net maybe there is something earlier than what I am doing wrong, since I am executing the action query and it does not modify the data either, maybe the SQL statement is wrong. I hope you can help me. Thank you.