本文发表在 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
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