I want to do a select by the current date, type: list all the data that was registered in my table today, I did it this way and it does not result in anything, it does not generate errors or list any of the information registered.
//Método Listar registos cadastrado Actualmente
public List<View_Caixa> Listar_Data()
{
List<View_Caixa> lis = new List<View_Caixa>();
SqlConnection conexao = new SqlConnection(caminho);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conexao;
cmd.CommandType = CommandType.Text;
string li = "select *from view_caixa where data_registo=@data_registo"; //É aqui onde eu faço o meu select
cmd.CommandText = li;
cmd.Parameters.AddWithValue("data_registo", DateTime.Now);
conexao.Close();
SqlDataReader dr;
conexao.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
View_Caixa obj = new View_Caixa();
obj.id_caixa = Convert.ToInt32(dr["id_caixa"].ToString());
obj.funcionario = dr["funcionario"].ToString();
obj.caixa_inicial = Convert.ToDecimal(dr["caixa_inicial"].ToString());
obj.total_veda_caixa = Convert.ToDecimal(dr["total_veda_caixa"].ToString());
obj.total_venda_multicaixa = Convert.ToDecimal(dr["total_venda_multicaixa"].ToString());
obj.total_multipagamento = Convert.ToDecimal(dr["total_multipagamento"].ToString());
obj.caixa_final = Convert.ToDecimal(dr["caixa_final"].ToString());
obj.conciliacao = Convert.ToDecimal(dr["conciliacao"].ToString());
obj.data_registo = Convert.ToDateTime(dr["data_registo"].ToString());
lis.Add(obj);
}
return lis;
}