Question : Sql syntax( datetime) problem

Experts
please see the following sql query and suggest me whether it is correct or wrong .
As it is not giving any o/p.

DateTime dt=DateTime.Today;
            using (SqlConnection con = new SqlConnection(Connectionstring.Connection))
            {
                string query = "select count(InteractionID) from Table_Interaction where reminderDate '" + dt + "' ";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        label2.Text = string.Format("{0}", reader[0]);
                    }
                }


            }

For more information please see the images attached for the table design.
Experts I am using Sql server 2005 not  sql server 2008.
Thanking you
Anindya
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
private void show_reminders()
        {
            DateTime dt=DateTime.Today;
            using (SqlConnection con = new SqlConnection(Connectionstring.Connection))
            {
                string query = "select count(InteractionID) from Table_Interaction where reminderDate '" + dt + "' ";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        label2.Text = string.Format("{0}", reader[0]);
                    }
                }


            }
        }
Attachments:
 
 
 
 

Answer : Sql syntax( datetime) problem

then:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
private void show_reminders()
        {
            DateTime dt=DateTime.Today;
            using (SqlConnection con = new SqlConnection(Connectionstring.Connection))
            {
                string query = "select count(InteractionID) from Table_Interaction where reminderDate >= @date and reminderDate < dateadd(day, 1, @date) ";
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    cmd.Parameters.Add("@date", dt);
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        label2.Text = string.Format("{0}", reader[0]);
                    }
                }


            }
        }
Random Solutions  
 
programming4us programming4us