×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

请问哪位会web service的?能否帮我看个问题?谢谢!!

本文发表在 rolia.net 枫下论坛我的web service如下:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Data.OleDb;

namespace SystemOne.NET
{
/// <summary>
/// Summary description for WebService1.
/// </summary>
public class DataLayer: System.Web.Services.WebService
{
private OleDbConnection getConnection()
{
String cnString = System.Configuration.ConfigurationSettings.AppSettings["connectInfo"] + HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["sourceName"]);
return new OleDbConnection(cnString);
}

//myConnection = Server.MapPath();


public DataLayer()
{
//
//
}
[WebMethod] public DataView getSites()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Sites", getConnection());

DataSet ds = new DataSet();
myCommand.Fill(ds, "Sites");
return ds.Tables["Sites"].DefaultView;
}
[WebMethod] public DataView getPreferredVendors()
{
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Site_Trade_Join", getConnection());

DataSet ds = new DataSet();
myCommand.Fill(ds, "Site_Trade_Join");
return ds.Tables["Site_Trade_Join"].DefaultView;
}

}
}

我从IE上run这个web service的时候,我得到如下的错误信息:

System.InvalidOperationException: You must implement the Add(System.Data.DataRowView) method on System.Data.DataView because it inherits from ICollection.

哪位高手知道这是怎么回事呢?谢谢!!更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请问哪位会web service的?能否帮我看个问题?谢谢!!
    本文发表在 rolia.net 枫下论坛我的web service如下:

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Web;
    using System.Web.Services;
    using System.Data.OleDb;

    namespace SystemOne.NET
    {
    /// <summary>
    /// Summary description for WebService1.
    /// </summary>
    public class DataLayer: System.Web.Services.WebService
    {
    private OleDbConnection getConnection()
    {
    String cnString = System.Configuration.ConfigurationSettings.AppSettings["connectInfo"] + HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["sourceName"]);
    return new OleDbConnection(cnString);
    }

    //myConnection = Server.MapPath();


    public DataLayer()
    {
    //
    //
    }
    [WebMethod] public DataView getSites()
    {
    OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Sites", getConnection());

    DataSet ds = new DataSet();
    myCommand.Fill(ds, "Sites");
    return ds.Tables["Sites"].DefaultView;
    }
    [WebMethod] public DataView getPreferredVendors()
    {
    OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from Site_Trade_Join", getConnection());

    DataSet ds = new DataSet();
    myCommand.Fill(ds, "Site_Trade_Join");
    return ds.Tables["Site_Trade_Join"].DefaultView;
    }

    }
    }

    我从IE上run这个web service的时候,我得到如下的错误信息:

    System.InvalidOperationException: You must implement the Add(System.Data.DataRowView) method on System.Data.DataView because it inherits from ICollection.

    哪位高手知道这是怎么回事呢?谢谢!!更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 我觉得这个错误信息不准确,我认为出错的原因是DataView不是serializable的,因此不能作为webmethod的参数或者返回值。试试改用dataset。
      • ok, let me try
      • 高手高手!!