Web服务返回Dataset对象
2009-04-20 12:52
225 查看
usingSystem;
usingSystem.Web.Configuration;
usingSystem.Web.Services;
usingSystem.Data;
usingSystem.Data.SqlClient;
usingSystem.Diagnostics;
///<summary>
///SummarydescriptionforCategoryService
///</summary>
[WebService(Namespace="http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
//ToallowthisWebServicetobecalledfromscript,usingASP.NETAJAX,uncommentthefollowingline.
//[System.Web.Script.Services.ScriptService]
publicclassCategoryService:System.Web.Services.WebService{
publicCategoryService(){
//Uncommentthefollowinglineifusingdesignedcomponents
//InitializeComponent();
}
[WebMethod]
publicDataSetGetCategoriesAsDataset()
{
try
{
using(SqlConnectionconn=newSqlConnection())
{
stringconnectionString=WebConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString;
conn.ConnectionString=connectionString;
SqlCommandcommand=newSqlCommand("select*fromProduction.ProductCategory",conn);
command.CommandType=CommandType.Text;
SqlDataAdapteradapter=newSqlDataAdapter(command);
DataSetcategories=newDataSet("Categories");
adapter.Fill(categories);
returncategories;
}
}
catch(Exceptionex)
{
EventLog.WriteEntry("Application",ex.Message);
throwex;
}
}
}
.csharpcode,.csharpcodepre
{
font-size:small;
color:black;
font-family:consolas,"CourierNew",courier,monospace;
background-color:#ffffff;
/*white-space:pre;*/
}
.csharpcodepre{margin:0em;}
.csharpcode.rem{color:#008000;}
.csharpcode.kwrd{color:#0000ff;}
.csharpcode.str{color:#006080;}
.csharpcode.op{color:#0000c0;}
.csharpcode.preproc{color:#cc6633;}
.csharpcode.asp{background-color:#ffff00;}
.csharpcode.html{color:#800000;}
.csharpcode.attr{color:#ff0000;}
.csharpcode.alt
{
background-color:#f4f4f4;
width:100%;
margin:0em;
}
.csharpcode.lnum{color:#606060;}
相关文章推荐
- 其他语言(JAVA)调用.NET Web服务返回的DataSet的问题
- 从Web服务中返回自定义对象
- Web项目在启动时启动一个服务或者实例化一个对象
- WCF服务返回JSON格式数据、配置web调用地址
- 不要将DataSet和Web服务混淆
- 数据库访问的一些公共的方法02-返回DataReader,DataSet,DataTable等对象
- 调用RESTFul服务,用Gson序列化返回对象
- 使用Yahoo!web服务的json(Javascript对象标识)
- 通过Web服务外置XML,将Web服务用作数据源,Web服务传递的内容是XML,将由Web服务返回的XML文档,以便可以将它加载到客户机上的XML分析器。
- 蛙蛙推荐: 用web服务传递Dataset的一个简单例子
- Java调用.NET XML Web Services返回的DataSet
- 请Artech,dudu 帮忙解答下: WCF 服务返回的如果是接口(remoting有个远程对象封送),(感觉比较难以解决的问题)
- [Sharepoint2007对象模型]第二回:Web应用程序服务(SPWebService)
- XMLHttpRequest 对象异步调用web服务
- 组装XML传给webserver+XML 返回获取多个xml,根据多个XML 返回dataset类型
- android调用C# 服务返回对象使用方法说明
- Web服务中的Session对象-学习
- iBatis.Net实现返回DataTable和DataSet对象
- 我用vs2005写了一个webservice用来查询sql2005数据库中表值,返回一个dataset类型集合,测试时候显示的xml文档没有问题,但是当我添加web引用的时候却无法正常显示而且报错原因之一。
- 一起谈.NET技术,Ajax和WEB服务数据格式:自定义返回格式