构建DataTable报错。。。
DataTable dt = new DataTable(); DataColumn can_use = new DataColumn(); can_use.DataType = System.Type.GetType("System.Int32"); can_use.ColumnName = "can_use"; dt.Columns.Add(can_use); DataColumn start_date = new DataColumn(); start_date.DataType = System.Type.GetType("System.DateTime"); start_date.ColumnName = "start_date"; dt.Columns.Add(start_date); DataColumn end_date = new DataColumn(); end_date.DataType = System.Type.GetType("System.DateTime"); end_date.ColumnName = "end_date"; dt.Columns.Add(end_date); DataColumn des = new DataColumn(); des.DataType = System.Type.GetType("System.String"); des.ColumnName = "des"; dt.Columns.Add(des); DataColumn gps_date = new DataColumn(); gps_date.DataType = System.Type.GetType("System.Boolean"); gps_date.ColumnName = "gps_date"; dt.Columns.Add(gps_date); dt = SQLHelper.ExecuteDateSet(conStr, CommandType.Text, sqlStr, null).Tables[0]; OracleDataReader dr = SQLHelper.ExecuteReader(conStr, CommandType.Text, sqlStr, null); DataRow dataRow; if (dr.HasRows) { while (dr.Read()) { string temp_canUse = dr["can_use"].ToString();//是否可用。1:可用,0:不可用 string temp_startDate = dr["start_date"].ToString();//空闲时间段开始时间 string temp_endDate = dr["end_date"].ToString();//空闲时间段结束时间 string temp_des = dr["des"].ToString();//描述 bool temp_gpsIsFree = IsEmpty(sim, DateTime.Parse(temp_startDate), DateTime.Parse(temp_endDate));//该段时间内是否有gps数据 dataRow = dt.NewRow(); dataRow["can_use"] = temp_canUse; dataRow["start_date"] = DateTime.Parse(temp_startDate); dataRow["end_date"] = DateTime.Parse(temp_endDate); dataRow["des"] = temp_des; dataRow["gps_date"] = true; dt.Rows.Add(dataRow); } }