我正在使用引用的日期选择器控件来选择日期。我得到错误
从字符串转换日期和/或时间时转换失败
public DataSet comsn(string x, DatePickerControl.DatePicker a, DatePickerControl.DatePicker b)
{
ConnectionStringSettings connectionstringsql = ConfigurationManager.ConnectionStrings["plprojectConnectionString"];
SqlConnection connectionsql = new SqlConnection(connectionstringsql.ConnectionString);
if (connectionsql.State != System.Data.ConnectionState.Open)
{
connectionsql.Open();
}
SqlCommand cmd = new SqlCommand("select a_id,commtyp,comm,primm,c_id,agent from comm where a_id= '" + x + "' AND date>= '" + a.CalendarDate + "' AND date <= '" + b.CalendarDate + "' ", connectionsql);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds, "comm"); //<------ At this line error occurred [ Conversion failed when converting date and/or time from character string ]
adp.Dispose();
return ds;
}