国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

利用WebClient獲取遠程數據(僅做備份)

2019-11-18 17:19:33
字體:
來源:轉載
供稿:網友

public DataSet GetData(string httpUrl)
              {
                     string xmlPath = @"http地址"; // 該地址不能包含中文
                     DataSet ds = new DataSet();
                     WebClient wc = new WebClient();
                     byte[] bt = wc.DownloadData(xmlPath); 
                     XmlDocument xd = new XmlDocument();

                     string source = Byte2String(bt);

                     xd.LoadXml(source);

                     XmlNodeReader xnr = new XmlNodeReader(xd);

                     ds.ReadXml(xnr);

 

                     DataTable dt = ds.Tables[0];

 

                     this.DataGrid1.DataSource = ds;

                     this.DataGrid1.DataBind();
  

                     return ds;  

              }

 

              public static string Byte2String(byte[] bt)

              {

                     System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("gb2312");

                     string str = encoding.GetString(bt);

                     return str;

              }


       
出處:http://www.brtech.com.cn


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上犹县| 小金县| 宜宾县| 巴林右旗| 凭祥市| 龙门县| 左权县| 门头沟区| 清远市| 丰镇市| 石城县| 黄梅县| 昌宁县| 石棉县| 江津市| 敦化市| 柳河县| 民勤县| 莱芜市| 邢台县| 毕节市| 左云县| 开封市| 易门县| 黄梅县| 防城港市| 木里| 六盘水市| 石河子市| 奈曼旗| 南宫市| 谢通门县| 东城区| 安西县| 镇巴县| 松溪县| 呼图壁县| 黄山市| 新宁县| 北流市| 绿春县|