从SQL服务器获取数据并使用C#将其作为XML发送到宁静的Web服务 [英] Getting data from SQL server and send that as XML to a restful webservice using C#
本文介绍了从SQL服务器获取数据并使用C#将其作为XML发送到宁静的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
我需要从外面获得一个需要将数据发布到xml的网址。
这个数据来自我的sql server。我需要使用C#来实现这一功能。
我尝试过:
我目前正在将这些数据写入文件。
我需要从数据库中每行执行此操作:
这是我到目前为止。
Hi all.
I need to get I have a url from outside that in need to post data to as xml.
this data comes from my sql server. I need to use C# for this functionality.
What I have tried:
Im currently writing this data to a file.
I need to do this per row from a database:
here is what I have so far.
connetionString = ConfigurationManager.ConnectionStrings["CompanyConnectionString"].ConnectionString;
connection = new SqlConnection(connetionString);
sql = "select * from Employee";
try
{
connection.Open();
adapter = new SqlDataAdapter(sql, connection);
adapter.Fill(ds);
connection.Close();
//Label1.Text = (ds.WriteXml);
ds.WriteXml("c:/temp/Product.xml");
Response.Write("Done");
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
推荐答案
大家好我刚刚决定用代码构建xml标签并在那里传递字段并使其正常工作。
Hi guys I have just decided to build xml tags withing the code and pass fields in there and got it working.
这篇关于从SQL服务器获取数据并使用C#将其作为XML发送到宁静的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文