Service 如何才能返回 DataTable和使用DataTable作为方法的参数,急...搞定就结贴
我想用DataTable来返回数据,我写了一下如下的方法来测试,结果返回后面的错误
[WebMethod]
public DataTable HelloWorld()
{
DataTable ResultTable = new DataTable("msgTable");
ResultTable.Columns.Add("Content",typeof(string));
ResultTable.Rows.Add(new object[]{"HelloWorld"});
return ResultTable;
}
错误:
类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NotSupportedException: 类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[NotSupportedException: 类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。]
System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source)
System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo)
System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo)
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
[InvalidOperationException: 反射类型“System.Data.DataTable”时出错。]
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType)
System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType)
System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement
----------------------------------
请问如何才能返回DataTable类型。
用DataSet 倒是可以返回,但是返回DataSet这样的数据类型,jsp可以调用吗?
[WebMethod]
public DataTable HelloWorld()
{
DataTable ResultTable = new DataTable("msgTable");
ResultTable.Columns.Add("Content",typeof(string));
ResultTable.Rows.Add(new object[]{"HelloWorld"});
return ResultTable;
}
错误:
类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NotSupportedException: 类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。
源错误:
执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
堆栈跟踪:
[NotSupportedException: 类型 System.ComponentModel.ISite 的成员 System.ComponentModel.MarshalByValueComponent.Site 是接口,因此无法将其序列化。]
System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo)
System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference)
System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source)
System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo)
System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo)
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
[InvalidOperationException: 反射类型“System.Data.DataTable”时出错。]
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType)
System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType)
System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers)
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement
----------------------------------
请问如何才能返回DataTable类型。
用DataSet 倒是可以返回,但是返回DataSet这样的数据类型,jsp可以调用吗?
...全文
相关推荐
C# 连接各种数据库返回DataTable的方法
`Fill`方法用于将数据库中的数据填充到`DataTable`中。在实际开发中,为确保安全性和性能,应使用参数化查询防止SQL注入,以及适当地关闭和释放数据库连接。
区块链相关技术、概念以及技术实现过程中的一些关键问题 Smart Contracts and Blockchains
2017年底,区块链已经成为众多投资人和技术人员最关注的话题之一。随着现实世界的不断复杂化、数字货币的流行以及IoT设备的普及,加密数字货币市场正变得越来越活跃。由于区块链具有去中心化、不可篡改、透明性、高并发等特点,使其在金融领域得到了广泛应用,尤其是在非洲国家、拉丁美洲等贫困地区。截止到2019年4月,全球已有超过4亿人加入到了加密数字货币市场。而随着区块链技术的发展,加密数字货币市场的规模将会继续扩大,未来将成为真正的去中心化金融平台。
springmvc+dataTable=Demo
DataTable 的使用则是在前端展示数据。开发者需要在HTML页面上引入DataTable的CSS和JS库,然后初始化DataTable实例,设置其各种选项。
jsf primefaces datatable
在`jsfDemo`中,我们可能使用Spring的`@Autowired`注解注入必要的服务,如数据库访问层(DAO)或业务逻辑层(Service)。5.
Silverlight 数据处理服务端传DataTable
这通常涉及到创建一个WCF服务代理,通过Add Service Reference或手动生成,使客户端能够调用服务端的方法。



