Display record greater than or equal to current date in ASP.Net DataList using C# and VB.Net

Last Reply 3 months ago By chetan

Posted 3 months ago

i wanted to display only upcoming events like 2019 events or for example say event from 29th december to 31st december2018.

i dont wanted to display the events which is already passed like from 21st december to 23rd december.Date is already passed.

i have the code as follows: 

    protected void showexhilist()
    {
        MySqlConnection conn = null;
        try
        {
            string connStr = ConfigurationManager.ConnectionStrings["ogpeConnectionString"].ToString();
            conn = new MySqlConnection(connStr);
            conn.Open();
            string sqlnews = null;
            sqlnews = "SELECT * FROM ogpe_exhibitions  where status=1 order by start_date desc";
            MySqlCommand cmd = new MySqlCommand(sqlnews, conn);
            MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            DataTable dt = new DataTable();
            dt.Load(dr);
            exiblist.DataSource = dt;
            exiblist.DataBind();
            conn.Close();
        }

        catch (Exception ex)
        {

        }
        finally
        {
            if (conn != null && conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }

how to achieve it?

http://ogpeafrica.com/Exhibitions.aspx?pageid=1

2018 events dates which is already over should not be shown.What changes are required in query?

any help will be apprecoiated.

You are viewing reply posted by: chetan 3 months ago.
Posted 3 months ago

Hi Sir,

i have used the following query and it worked.

sqlnews = "SELECT * FROM ogpe_exhibitions  where status=1 and DATE(start_date) > DATE(NOW()) order by start_date";