asp.net 数据库查询出错??
报错提示
<br />
<b>Fatal error</b>: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime
在 MySql.Data.Types.MySqlDateTime.GetDateTime()
在 MySql.Data.MySqlClient.MySqlDataReader.GetValue(Int32 i)
在 MySql.Data.MySqlClient.MySqlDataReader.GetValues(Object[] values)
在 System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
在 System.Data.ProviderBase.SchemaMapping.LoadDataRow()
在 System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
在 System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
在 System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32
[WebMethod(Description = "内容信息")] public string ContentInfo(string param) { string total = ""; string result_head = "<contents>"; string result_foot = "</contents>"; string result = ""; string query = "select * from talk left join reply on talk.id='"+param+"' and reply.rid='"+param+"' where reply.rid is not null"; MySqlConnection myConnection = new MySqlConnection("server=localhost;user=xxxx;password=xxx;database=xxx;charset=utf8"); DataSet ds = new DataSet(); DataTable dtable; DataRowCollection dc; DataRow drow; myConnection.Open(); MySqlDataAdapter sqld = new MySqlDataAdapter(query, myConnection); sqld.Fill(ds, "con"); dtable = ds.Tables["con"]; dc = dtable.Rows; if (dc.Count == 0) {//运行这里的查询出错 ds.Clear(); MySqlDataAdapter sqld2 = new MySqlDataAdapter("select * from talk,reply where talk.id='" + param + "' and reply.fuzhuid=1", myConnection); sqld2.Fill(ds, "con2"); DataTable dtable2 = ds.Tables["con2"]; DataRowCollection dc2 = dtable2.Rows; dc2 = dtable2.Rows; for (int i = 0; i < dc2.Count; i++) { DataRow drow2 = dc2[i]; String title = Regex.Replace(drow2["title"].ToString(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); String con = Regex.Replace(drow2["content"].ToString(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); result += "<content><id>" + drow2["id"] + "</id><name>" + drow2["zuozhe"] + "</name><title>" + title + "</title><time>" + drow2["time1"] + "</time><con>" + con + "</con><zuozhe1>" + "" + "</zuozhe1><con1>" + "" + "</con1><time2>" + "" + "</time2></content>"; } total = result_head + result + result_foot; } else {//运行这里的查询没问题,正常显示数据 for (int i = 0; i < dc.Count; i++) { drow = dc[i]; String title = Regex.Replace(drow["title"].ToString(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); String con = Regex.Replace(drow["content"].ToString(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); String con1 = Regex.Replace(drow["content1"].ToString(), @"<(.[^>]*)>", "", RegexOptions.IgnoreCase); result += "<content><id>" + drow["id"] + "</id><zuozhe>" + drow["zuozhe"] + "</zuozhe><title>" + title + "</title><time>" + drow["time1"] + "</time><con>" + con + "</con><zuozhe1>" + drow["zuozhe1"] + "</zuozhe1><con1>" + con1 + "</con1><time2>" + drow["time2"] + "</time2></content>"; } total = result_head + result + result_foot; myConnection.Close(); } return total; }