在WCF Service中返回并调用DataSet类型对象的示例
说明:本WCF Service是在 IIS中发布的
WCF Service服务部分:
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using System.IO;
namespace KGE.JL.Data.Calc
{
[ServiceContract()]
public interface IJLDataCalc
{
[OperationContract]
DataSet GetTaskTypeTreeData(string parentID);
}
public class JLDataCalcCLS : IJLDataCalc
{
public DataSet GetTaskTypeTreeData(string parentID) //这里返回一个DataSet
{
string sql = "select oi_id2f,oi_name2f from hz_group_v where oi_id1f = " + parentID;
Database db = DatabaseFactory.CreateDatabase();
return db.ExecuteDataSet(CommandType.Text, sql);
}
}
}
调用部分:
1、先引用服务
2、调用代码如下:
localhost.JLDataCalcClient t = new WindowsApplication1.localhost.JLDataCalcClient();
MessageBox.Show(t.GetTaskTypeTreeData("-1").Tables.Count.ToString());
posted on 2008-02-21 08:40 Above The Sky 阅读(287) 评论(0) 编辑 收藏 举报