-1
Thank you from now on,
Using Visual Studio and Mysql: I need to display in my GRID a list of products that only where the 'stock' field is smaller than the 'minimum' field of my Products Table'.
I can already put the direct value in the line (ex.: value 15) cmd.Parameters.Addwithvalue("@stock", 15);
see q declare the value 15. But I have a field where when registering the ITEM I determine what will be the minimum value.
is an excerpt from the code:
//my grid is listed like this:
private void List() {
con.AbrirConexao();
sql = "SELECT pro.id, pro.cod, pro.nome, pro.descricao, pro.estoque, forn.nome, pro.entrada, pro.total_compra, pro.valor_compra, pro.valor_venda, pro.data, pro.imagem, pro.fornecedor, pro.minimo, pro.nota FROM produtos as pro INNER JOIN fornecedores as forn ON pro.fornecedor = forn.id WHERE **estoque < @estoque** ORDER BY pro.nome asc";
cmd = new MySqlCommand(sql, con.con);
cmd.Parameters.AddWithValue("**@estoque", 15**);
MySqlDataAdapter da = new MySqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
da.Fill(dt);
grid.DataSource = dt;
con.FecharConexao();
FormatarGD();
}
//How do I stop instead of putting the fixed value 15 in the code, search the 'minimum' field of the same table 'products' ?
Just pass a variable in place of the number :D
– Murilo Melo