How to get a DataTable from Web Service

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?
 
C

Cor Ligthert [MVP]

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
 

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

Top