How to pass Date parameter from asp.net C# to sql server using sql command parameters
Error i am getting is "Invalid cast from 'DateTime' to 'Int32'.Couldn't store <10/3/2017 12:00:00 AM> in Date Column. Expected type is Int32."
The Code is
Cmd.Parameters.Add(new SqlParameter("@StartDate", Convert.ToDateTime(txtFromDate.Text).ToShortDateString()));
Cmd.Parameters.Add(new SqlParameter("@EndDate", Convert.ToDateTime(txtFromDate.Text).ToShortDateString()));
Cmd.CommandType = CommandType.StoredProcedure;
DA = new SqlDataAdapter(Cmd);
and Stored Procedure Parameters are
@StartDate DATE = NULL,
@EndDate DATE = NULL
How to pass the data to Stored Procedure.