chris 0

chris 0

  • NA
  • 6
  • 0

Problem returning ArrayList from webservice

Aug 26 2005 8:33 AM
Hi everyone.

I don't often use web services, so could be missing something here, but I'm really stumped.

I have created two web services, one of which seems to work exactly as it should. In that webservice, i have the following code:

public ArrayList GetItems(int repid)

{

SQLConnection sql=new SQLConnection();

sql.Open();

ArrayList items=new ArrayList();

OleDbDataReader dr=sql.Get_DataReader("Select lblname, Ftooltip, maxlength, itemindex, id from form where repid="+repid+" order by itemindex");

while (dr.Read())

{

items.Add(new string[] {dr.GetString(0), dr.GetString(1), dr.GetInt32(2).ToString(), dr.GetInt32(4).ToString()});

}

dr.Close();

sql.Close();

return items;

}

This does what it should, and returns an array of type object[], where each instance is of type string[]. Fine.

In another webservice, I have this code: (different project, but both are C#.net webservices)

public ArrayList GetMsgHeaders()

{

SQLConnection sql=new SQLConnection();

sql.Open();

ArrayList info=new ArrayList();

OdbcDataReader dr=sql.Get_DataReader("Select * from message");

while (dr.Read())

{

info.Add(new string[] {dr.GetInt32(0).ToString(), dr.GetString(1), dr.GetInt32(3).ToString()});

}

dr.Close();

sql.Close();

return info;

}

Now, i thought they were much the same thing, but when I use this one, the application crashes, telling me:

Additional information: Server was unable to process request. --> There was an error generating the XML document. --> The type System.String[] may not be used in this context.

What have I done wrong?!