Newbie: does not have a parameterless constructor

Discussion in 'ASP .Net Web Services' started by vncntj, Nov 25, 2007.

  1. vncntj

    vncntj Guest

    I'm working on my first Web Service and need to display data from a
    Sql Database. I get this error message:

    "Telemarketing.TUsers cannot be serialized because it does not have a
    parameterless constructor."



    I have my "proxy ?" content page TUsers.cs

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data.SqlClient;
    using System.Data;

    namespace Telemarketing
    {
    public class TUsers
    {

    #region Properties
    private string mReason;
    private string mReid;

    public string Reason
    {
    get
    {
    return mReason;
    }
    set
    {
    mReason = value;
    }
    }

    public string Reid
    {
    get
    {
    return mReid;
    }
    set
    {
    mReid = value;
    }
    }

    #endregion

    #region Methods
    public TUsers(string Reason, string Reid)
    {
    mReason = Reason;
    mReid = Reid;
    }

    }
    #endregion

    public class ListTUsers
    {

    public List<TUsers> TUsers
    {
    get
    {
    List<TUsers> lst = new List<TUsers>();

    DataTable dt = GetTUsers().Tables["tno"];
    foreach (DataRow dr in dt.Rows)
    {
    TUsers t = new TUsers(dr["Reason"].ToString(),
    dr["Re_id"].ToString());
    lst.Add(t);
    }
    return lst;
    }
    }

    internal DataSet GetTUsers()
    {
    string SQL = "Select Reason, Re_id From tno";
    SqlDataAdapter da = new SqlDataAdapter(SQL, Conn.ConnString);
    DataSet ds = new DataSet();
    da.Fill(ds, "tno");
    return ds;
    }
    }
    }




    and the BlogService.cs codebehind page for BlogService.asmx


    using System;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Collections.Generic;
    using Telemarketing;

    /// <summary>
    /// Summary description for BlogService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class BlogService : System.Web.Services.WebService {

    public BlogService () {

    //Uncomment the following line if using designed components
    //InitializeComponent();
    }

    [WebMethod()]
    public List<Telemarketing.TUsers> ListTUsers()
    {
    ListTUsers lt = new ListTUsers();
    return lt.TUsers;

    }
    }


    Thanks
     
    vncntj, Nov 25, 2007
    #1
    1. Advertising

  2. vncntj

    vncntj Guest

    I figured it out.
    Thanks.
     
    vncntj, Nov 25, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. simon place
    Replies:
    4
    Views:
    345
    simon place
    Mar 7, 2004
  2. Nathan Sokalski
    Replies:
    1
    Views:
    2,536
    Gaurav Vaish \(www.EdujiniOnline.com\)
    Nov 21, 2006
  3. asdf
    Replies:
    2
    Views:
    347
  4. Generic Usenet Account
    Replies:
    10
    Views:
    2,286
  5. Julia B
    Replies:
    8
    Views:
    518
    Mike Baker
    Nov 21, 2008
Loading...

Share This Page