ricardo rosa

ricardo rosa

  • NA
  • 20
  • 0

Help with error after debug

Feb 26 2010 6:57 AM

I have this code
 
using
System;
using
System.Collections;
using
System.ComponentModel;
using
System.Data;
using
System.Data.SqlClient;
using
System.Diagnostics;
using
System.Web;
using
System.Web.Services;
namespace
APPRECWS
{
/// <summary>
/// Summary description for Service1.
/// </summary>
public class AplicationRecordWS : System.Web.Services.WebService
{
public AplicationRecordWS()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}

#region
Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion

// WEB SERVICE EXAMPLE
// The HelloWorld() example service returns the string Hello World
// To build, uncomment the following lines then save and build the project
// To test this web service, press F5
// [WebMethod]
// public string HelloWorld()
// {
// return "Hello World";
// }
[WebMethod]

public DataResult GetData(SearchInformation InputData)
{
SqlConnection conn =
new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd =
new SqlCommand("spFAWebServiceWC",conn);

cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@BusinessSeg",InputData.BusinessSeg);
cmd.Parameters.Add("@BusinessBan",InputData.BusinessBan);
cmd.Parameters.Add("@BusinessType",InputData.BusinessType);
cmd.Parameters.Add("@ApplicatioName",InputData.ApplicatioName);
cmd.Parameters.Add("@ApplicationShortName",InputData.ApplicationShortName);
cmd.Parameters.Add("@RBS",InputData.RBS);
conn.Open();
SqlDataReader dados = cmd.ExecuteReader();
conn.Close();

DataResult resultado =
new DataResult();
ApplicationInformation appInfo;
while(dados.Read())
{
appInfo =
new ApplicationInformation();
appInfo.ApplicationID =
int.Parse(dados["ApplicationID"].ToString());
appInfo.BusinessBan =
int.Parse(dados["BusinessBan"].ToString());
appInfo.BusinessSeg =
int.Parse(dados["BusinessSeg"].ToString());
appInfo.BusinessType = dados["BusinessType"].ToString();
appInfo.ApplicationName = dados["ApplicationName"].ToString();
appInfo.ApplicationShortName = dados["ApplicationShortName"].ToString();
appInfo.RBS = dados["RBS"].ToString();
appInfo.SystemType = dados["SystemType"].ToString();
appInfo.Status = dados["Status"].ToString();
resultado.Add(appInfo);
}

return resultado;
}
public class SearchInformation
{
public string BusinessSeg;
public string BusinessBan;
public string BusinessType;
public string ApplicatioName;
public string ApplicationShortName;
public string RBS;
}
public class ApplicationInformation
{
public int ApplicationID;
public int BusinessSeg;
public int BusinessBan;
public string BusinessType;
public string ApplicationName;
public string ApplicationShortName;
public string RBS;
public string SystemType;
public string Status;
}

//http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx
public class DataResult : CollectionBase, IEnumerable
{
public void Add(ApplicationInformation umRegisto)
{
List.Add(umRegisto);
}
public void Add(DataResult oRegistos)
{
for(int x=0;x<oRegistos.Count;x++)
{
List.Add(oRegistos.Item(x));
}
}
public void Remove(int index)
{
if (index > Count - 1 || index < 0)
{
throw new Exception("Index out of bounds");
}

List.RemoveAt(index);
}
public ApplicationInformation Item(int index)
{
if (index > Count - 1 || index < 0)
{
throw new Exception("Index out of bounds");
}
return (ApplicationInformation) List[index];
}
}
}
}
 
 
and it gives no errors when debugging but when it tries to open the page this error happens:
 

Server Error in '/APPRECWS' Application.

You must implement a default accessor on APPRECWS.AplicationRecordWS+DataResult because it inherits from ICollection.


 
I'm using VS2003, Can anyone help me please?
Thanks in advance
 
Ricardo Rosa

Answers (5)