110,571
社区成员
发帖
与我相关
我的任务
分享
[WebMethod(Description = "get content from SQLSERVER",CacheDuration = 600, MessageName = "GetContent")]
public XmlDataDocument GetContent()
{
SqlConnection SqlConn;
string connectionString = "Server=Cecil-PC\\SQLSERVER2005;User Id=sa;Pwd=;DataBase=test0317";
SqlConn = new SqlConnection(connectionString);
//string commandstring = "select s_name,s_birthday,s_native_place from dbo.staff order by s_id FOR XML AUTO";
string commandstring = "select * from dbo.staff for xml auto";
SqlCommand command = new SqlCommand(commandstring, SqlConn);
SqlConn.Open();
XmlReader reader = command.ExecuteXmlReader();
System.Web.HttpContext.Current.Response.Write(Server.HtmlEncode(reader.ReadOuterXml() + "<br>"));
reader.Read();
XmlDataDocument xml = new XmlDataDocument();
xml.Load(reader);
reader.Close();
return xml;
}