I have a form with 2 dateTimePicker controls (dtpStart and dtpEnd), a button, and a datagridview to show results. The datagridview is bound to a bindingSource control.
I want to pass two date parameters from the dateTimePicker controls to the stored procedure in order to return the required scope on my datagridview.
My stored procedure looks like this:
CREATE PROC [dbo].[ProcTest](@StartDate date, @EndDate date)
AS
SELECT * FROM Test WHERE ModifiedDate BETWEEN @StartDate AND @EndDate
My C# code is:
private void button1_Click(object sender, EventArgs e)
{
dc = new NorthwindDataContext();
var Qry = dc.ProcTest(dtpStart.Value, dtpEnd.Value);
bindingSource1.DataSource = Qry;
}
When I run the code above I receive nothing on my datagrid, the dtpEnd.value shows: 13/08/2012 02:15:29, I assume that this is a conversion issue since I use date type in my stored procedure and the datetimepicker value is a dateTime type.
Please, how to resolve this ?
List<T>- dataGridView1.DataSource=res.ToList();