从WCF服务返回ArrayList [英] Return ArrayList from WCF Service
本文介绍了从WCF服务返回ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在实现WCF服务,因为我正在将数据集转换为arraylist并在我运行代理时返回此menthod不可调用且显示!这个标记
以下是我的代码
i am implementing WCF service in that i am converting dataset to arraylist and returning when i run the proxy this menthod not invokable and it showing "!" this mark
below is my code
namespace WCFService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{
[OperationContract]
Customer GetCustomer(int id);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class Customer
{
[DataMember]
public ArrayList GetCust
{
get;
set;
}
}
}
namespace WCFService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public Customer GetCustomer(int id)
{
SqlConnection con = new SqlConnection("Data Source=.;Database=Temp;Integrated Security=true");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from tblCustomerInfo_Bangalore where CID = "+id;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
Customer cu = new Customer();
ArrayList list = new ArrayList();
foreach (DataRow row in ds.Tables[0].Rows)
{
list.Add(row);
}
cu.GetCust = list;
return cu;
}
}
}
任何人都可以帮我解决这个问题.... ..
谢谢。
can any body help me out in this......
thank you.
推荐答案
Hello chetan BY,
试试..
SqlCommand cmd = new SqlCommand(con );
代替
SqlCommand cmd = new SqlCommand ();
这可能对你有用(对不起,如果我错了..)
Hello chetan B Y,
Try..
SqlCommand cmd = new SqlCommand(con);
in place of
SqlCommand cmd = new SqlCommand();
This may Work out for you(sorry if i''m wrong..)
这篇关于从WCF服务返回ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文