日期:2014-05-17 浏览次数:20506 次
[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
{
//运行这里的查询没问题,正常