读书人

高手给个好用的web service代码吧解决

发布时间: 2012-05-28 17:59:33 作者: rapoo

高手给个好用的web service代码吧

C# code
[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];                    //此处省略                }                total = result_head + result + result_foot;                        }            else            {//运行这里的查询没问题,正常显示数据                for (int i = 0; i < dc.Count; i++)                {                    drow = dc[i];                   //此处省略                }                total = result_head + result + result_foot;                myConnection.Close();            }            return total;        }



为什么会错啊。。。有什么好的代码替换替换

[解决办法]
没有看懂你是什么意思,
[解决办法]
仔细检查一下吧

读书人网 >asp.net

热点推荐