如何读取一个webservers接口
浏览量:4636
有些客户往往要求读取一个接口中的数据,给了接口,读取出来了,但是如何转换成自己数据库中的数据呢?
首先要添加Webservers, 在下面红框中输入Url:
1 实例化对象:
引用名. CollectionService obj=new引用名. CollectionService();
2调取方法:
System.Xml.XmlNode xml = obj.方法名("用户名", "密码");
3.读取xml
DataSetds = new DataSet();
// 读取XML字符串到XmlNodeReader中,再转化成Dataset
XmlNodeReader reader = new XmlNodeReader(xml);
{
ds.ReadXml(reader);
}
现在已经把从接口中读取的数据绑定到了你要绑定中的地方。
#region网站数据与远程数据混排
if (paixu == "0")
{
foundRows = dt.Select(" " + valuelist + " ", " lzjiage " + paixutype1 + ", lzzhongliang " + paixutype2 + ", lzjingdu " + paixutype3 + " , lzyanshe " + paixutype4 + ", lzqiegong " + paixutype5 + " ");
}
if (paixu == "1")
{
foundRows = dt.Select(" " + valuelist + " ", " lzzhongliang " + paixutype2 + " ,lzjiage " + paixutype1 + " , lzjingdu " + paixutype3 + " , lzyanshe " + paixutype4 + ", lzqiegong " + paixutype5 + " ");
}
if (paixu == "2")
{
foundRows = dt.Select(" " + valuelist + " ", " lzjingdu " + paixutype3 + ", lzzhongliang " + paixutype2 + " ,lzjiage " + paixutype1 + " , lzyanshe " + paixutype4 + ", lzqiegong " + paixutype5 + " ");
}
if (paixu == "3")
{
foundRows = dt.Select(" " + valuelist + " ", " lzyanshe " + paixutype4 + " , lzjingdu " + paixutype3 + ", lzzhongliang " + paixutype2 + " ,lzjiage " + paixutype1 + " ,lzqiegong " + paixutype5 + " ");
}
if (paixu == "4")
{
foundRows = dt.Select(" " + valuelist + " ", " lzqiegong " + paixutype5 + " ,lzyanshe " + paixutype4 + " , lzjingdu " + paixutype3 + ", lzzhongliang " + paixutype2 + " ,lzjiage " + paixutype1 + " ");
}
//dt.Clear();
这样就把数据混排到了数据库数据中了。