-2
Good Afternoon! Personal, I’m new in C# and would like to know how I make a query using Datetimepicker in the BETWEEN of a select, below is my code.
public static DataTable ListarPrevisoesGrid()
{
DataTable dt = new DataTable();
try
{
var vcon = ConnDataBase();
var cmd = vcon.CreateCommand();
{
cmd.CommandText = "SELECT p.nome,v.vencimento,v.valor FROM pessoa p INNER JOIN pedido pd ON p.idpessoa = pd.fornecedor INNER JOIN pedvenc v ON v.idpedido = pd.idpedido WHERE v.vencimento BETWEEN '2021-07-01' AND '2021-07-30' AND pd.cnsstatus = 'PREVFIN' AND pd.cnscanmom IS NULL ORDER BY nome ASC";
MySqlDataAdapter da = new MySqlDataAdapter(cmd.CommandText, ConnDataBase());
da.Fill(dt);
vcon.Close();
return dt;
}
}
catch (Exception ex)
{
throw ex;
}