当前位置: 代码迷 >> ASP.NET >> 高手给个好用的web service代码吧解决方法
  详细解决方案

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

热度:369   发布时间:2013-02-25 00:00:00.0
高手给个好用的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;        }



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

------解决方案--------------------------------------------------------
没有看懂你是什么意思,
------解决方案--------------------------------------------------------
仔细检查一下吧
  相关解决方案