How to get a DataTable from Web Service

  • Thread starter Thread starter ad
  • Start date Start date
A

ad

I have a method in WebServcie, which retrun a DataTable:
[WebMethod]
public DataTable GetSchoolList()
{
string sSql = "Select ....";
DataTable dt ;
.........
return dt;
}


In the consume application, I have add the reference to that web service,
and use the codes to get the datatabe.

localhost.Health wsHealth = new localhost.Health();
DataTable dt = (DataTable)wsHealth.GetSchoolList("413");


But it result in an error when compile:

Error 21 Cannot convert type
'localhost.GetSchoolListResponseGetSchoolListResult' to
'System.Data.DataTable'

I thought the return type is DataTable, why it become to
GetSchoolListResponseGetSchoolListResult?
 
Ad,

Embed the datatable just in a dataset. That dataset is the serialized format
for it. (In the version 2005 you see that standard done).

I hope this helps,

Cor
 
Back
Top