Wednesday, 21 August 2013

How to do Web Method for List in C#?

How to do Web Method for List in C#?

I have the Web Method.
[WebMethod]
public List<string[]> getObjective()
{
List<string[]> objectiveStringList = new List<string[]>();
con.dbConnect();
objectiveStringList = con.getObjective();
con.dbClose();
return objectiveStringList;
}
And also, the query.
public List<string[]> getObjective()
{
string strCMD = "SELECT objective FROM CorrespondingBall WHERE
objective IS NOT NULL";
SqlCommand cmd = new SqlCommand(strCMD, conn);
SqlDataReader dr = cmd.ExecuteReader();
List<string[]> objectiveStringList = new List<string[]>();
while (dr.Read())
{
objectiveStringList.Add((string[])dr["objective"]);
}
return objectiveStringList;
}
However, error "HTTP 500 Internal Server Error" message was shown. I have
tried it with List Byte Array and there was no error. Does anyone know how
can I solved it?
FYI: I am doing an application for Windows Phone 7.

No comments:

Post a Comment