To elaborate a bit more as an extension to Phil's answer: the reason is because 
a datarow relies on the columns collection of the
containing datatable: a datarow's value on position 3 has no meaning unless you 
know what the column is on position 3.

So, you can't instantiate a datarow without having it placed inside a 
datatable, this thus means there's no constructor you can call
to instantiate a datarow, you can only create a datarow through a datatable.

Thus this also means that serializing solely a datarow doesn't make any sense 
as the deserialized data has no real meaning: there
are no columns available.

        FB

> datarow does not implement iserializable and is not marked
> Serializable()
>
> i wouldn't suggest asking about a parameterless ctor on the
> 'ADVANCED-DOTNET' list.  maybe try the VBDOTNET list as a
> better place to post this question.
>
> basically it means the datarow does not have a method called
> New() that takes no arguments.
>
>
> -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] Behalf Of
> Manoj Aggarwal
> Sent: Wednesday, October 18, 2006 9:47 AM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: Re: [ADVANCED-DOTNET] Serializing a datarow in webservices
>
>
> Can you please explain why is it so...
> Also It will be helpful if u can explain what is "datarow
> with parameterless constructor", an example will help me a
> long way -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of Phil Sayers
> Sent: Wednesday, October 18, 2006 06:36 PM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: Re: [ADVANCED-DOTNET] Serializing a datarow in webservices
>
> a datarow is not serializable.
> you should return a datatable with a single row in it....or a
> custom object that contains the information.
>
> -----Original Message-----
> From: Discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] Behalf Of
> Manoj Aggarwal
> Sent: Wednesday, October 18, 2006 2:08 AM
> To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
> Subject: [ADVANCED-DOTNET] Serializing a datarow in webservices
>
>
> Dear Friends,
>
> I am trying the return a datarow from a webmethod.
> I am getting the following error when I try to add the
> webreference in my windows forms code:
>
> DSOrders.DTInvoiceSelectByBookingIdRow can not be serialized
> because it does not have parameterless constructor.
>
> I am using the following code:
> [WebMethod]
> public DSOrders.DTInvoiceSelectByBookingIdRow
> GetInvoiceByBookingId(Int64
> BookingId)
>     {
>         DAInvoiceSelectByBookingId objDa = new
> DAInvoiceSelectByBookingId();
>         DSOrders.DTInvoiceSelectByBookingIdDataTable dtInvoice;
>         try
>         {
>             dtInvoice = objDa.GetInvoiceByBookingId(BookingId);
>         }
>         catch (Exception ex)
>         {
>             throw ex;
>         }
>         if (dtInvoice.Rows.Count == 0)
>         {
>             throw new Exception("Invalid BookingId");
>         }
>         DSOrders.DTInvoiceSelectByBookingIdRow dr =
> (DSOrders.DTInvoiceSelectByBookingIdRow)dtInvoice.Rows[0];
>         return dr;
>     }
>
>
> Tried to google, but of now use.
>
> Thanks,
> Manoj
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor.  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to