Newbie: does not have a parameterless constructor

V

vncntj

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top