Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / September 2004

Tip: Looking for answers? Try searching our database.

HELP: must implement the Add(System.Data.DataRowView) Method?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grigs - 27 Sep 2004 16:17 GMT
I have a C# Web Service that some of the methods (ones that return integers)
work and some do not (the ones that return a DataView.

Here is some code in the WebService that is giving me the problem.  The
oAllData function gets run on the initialization of the class.

   DataSet oAllData = new DataSet();

   [WebMethod(Description="Return a DataView of the Active Notifications")]
   public object GetActiveNotifications() {
     DataView oNeededData = new DataView(oAllData.Tables["Notification"]);
     oNeededData.RowFilter = "Status = 'Active'";

     return oNeededData;
   }

   private DataSet ConnectToDataStore() {
     DataSet oDS = new DataSet();
     oDS.ReadXml(Server.MapPath("NAAData.xml"));
     return oDS;
   }

Here is the code that runs when I click a button.  It is supposed to pass
back a DataView and then I would bind that to a DataGrid.

   private void cmndGetNotifications_Click(object sender, System.EventArgs
e) {
     TestNANAA.NAWS.NANAA oWS = new TestNANAA.NAWS.NANAA();
     DataView oDV = new DataView();
     oDV = (DataView)oWS.GetActiveNotifications();
     dgrdData.DataSource = oDV ;
     dgrdData.DataBind();
   }

However, when I click the button to do it I get the following error:

Server was unable to process request. --> There was an error generating the
XML document. --> You must implement the Add(System.Data.DataRowView) method
on System.Data.DataView because it inherits from ICollection

Line 92:          
RequestNamespace="http://www.NAMfg.com/NAMfgWebServices/NotificationsAndAlerts/",
ResponseNamespace="http://www.NAMfg.com/NAMfgWebServices/NotificationsAndAlerts/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 93:         public object GetActiveNotifications() {
Line 94:             object[] results =
this.Invoke("GetActiveNotifications", new object[0]);
Line 95:             return ((object)(results[0]));
Line 96:         }

I need some help here.  Pulling my hair out trying to figure out what to do.

TIA,
Kevin
Signature

Thanx,
Grigs

Sami Vaaraniemi - 28 Sep 2004 12:02 GMT
> I have a C# Web Service that some of the methods (ones that return integers)
> work and some do not (the ones that return a DataView.
[quoted text clipped - 37 lines]
>
> Line 92:

RequestNamespace="http://www.NAMfg.com/NAMfgWebServices/NotificationsAndAler
ts/",

ResponseNamespace="http://www.NAMfg.com/NAMfgWebServices/NotificationsAndAle
rts/",
> Use=System.Web.Services.Description.SoapBindingUse.Literal,
> ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[quoted text clipped - 5 lines]
>
> I need some help here.  Pulling my hair out trying to figure out what to do.

Hi Kevin,

The short story is that you cannot return a DataView from a WebMethod
because a DataView is not XML serializable (for more information, read
http://support.microsoft.com/default.aspx?scid=kb;en-us;306134 and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conxmlserializationwithwebservices.asp
).

Instead of a DataView, you will need to return something that can be
serialized to XML, e.g., a DataSet or an array of custom objects.

Regards,
Sami
Grigs - 28 Sep 2004 15:03 GMT
Understood.  Well, I am dealing with it at least.
Thank you, what I have done to get around the issue was when I returned a
DataSet that always worked.  However, my initial DataSet has 5 tables in it.  
I have adjusted the WS to now create an empty DataSet and add new DataTable
and I fill in the values and return that.

Works like a champ, thanks again,
Kevin

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.