In winform app i have a datagridview for showing the database values. i use these following codes to see the result between two specific datetime for example between 6/5/2010 and 7/5/2010 but it just show me the rows which exactly updated in these datetime. i mean it just show me the rows which has exact Registrationday and finish day. i want to see all the results between these times.
private void button1_Click(object sender, EventArgs e)
{
sql = new SqlConnection(@"Data Source=PC-PC\PC;Initial Catalog=Test;Integrated Security=True");
adapter = new SqlDataAdapter("select EntryID,Name,FamilyName,Registrationday,Finishday,Fee from Entry where Registrationday =@Registrationday AND Finishday =@Finishday", sql);
adapter.SelectCommand.Parameters.AddWithValue("@Signday", Convert.ToDateTime(textBox1.Text).ToShortDateString());
adapter.SelectCommand.Parameters.AddWithValue("@Finishday", Convert.ToDateTime(textBox2.Text).ToShortDateString());
dt = new DataTable();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
}
For rows overlapping your interval:
This matches all the following rows:
For rows contained entirely within your interval:
This matches only these rows: