我从Winforms应用程序中的DateTimePicker中获取两个日期,并针对这两个日期运行SQL查询并将输出保存在Excel中。我使用以下代码。它正在抛出异常
将表达式转换为数据类型datetime的算术溢出错误
请协助解决此问题
DateTime startdate = dPStartDate.Value;
DateTime enddate = dPEndDate.Value;
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connString;
string query = "Select Incident_Number from HELP_DESK where Assigned_Group = 'Compliance' and Submit_Date between @startdate and @enddate";
SqlCommand command = new SqlCommand(query, conn);
command.Parameters.AddWithValue("@startdate", startdate);
command.Parameters.AddWithValue("@enddate", enddate);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
ds.WriteXml(@"c:/File_Name.XLS");
conn.Close();