我需要乘以列valorprod * cantidad并显示一个名为小计的新列
代码在这里
DataTable dsDetalle = new DataTable("Data");
using (MySqlCommand commandSql = cn.CreateCommand())
{
commandSql.CommandType = CommandType.Text;
commandSql.CommandText = "select * from detalle where idVenta=@idVenta and idlocal=@idlocal";
commandSql.Parameters.AddWithValue("@idVenta", txt_boleta.Text);
commandSql.Parameters.AddWithValue("@idlocal", txtlocal.Text);
MySqlDataAdapter sqlAdapter = new MySqlDataAdapter(commandSql);
sqlAdapter.Fill(dsDetalle);
}
答案 0 :(得分:1)
您可以动态创建计算列。
commandSql.CommandText = @"
SELECT *, ( valorprod * cantidad ) AS subtotal
FROM detalle
WHERE idVenta = @idVenta AND idlocal = @idlocal";