Last post Mar 25, 2013 01:53 AM by soliram28
Mar 18, 2013 01:38 PM|dofoo|LINK
I'm building a web service, this is my method:
public DataTable DatiGis(string poly)
SqlConnection con = new SqlConnection(connectionString);
//SqlConnection myConnection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("interseca", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
The error I get is about the serialize of the datatable. Where am I wrong?
Mar 18, 2013 01:44 PM|dofoo|LINK
but the error still happen..
Mar 20, 2013 06:11 AM|Haixia Xie - MSFT|LINK
The DataTable, DataRow, DataView, and DataViewManager objects cannot be serialized and cannot be returned from an XML Web service. To return less than a complete DataSet, you must copy the data that you want to return to a new DataSet. The solution is to return
a DataSet instead of a DataTable. Please find details in a kb below.
#Problems using an XML Web service that returns a DataTable
Mar 25, 2013 01:53 AM|soliram28|LINK
Check out the below,its really help u
You can return DataTable in WebService. You just need to give full DataTable name. e.g DataTable dt = new DataTable("YourTableName"); That's all. To return object in web service, Microsoft need to serialize the object. At that time your data table object
must has name. So, Microsoft will convert to XML like <------ -----> If your table has no name, Microsoft cannot serialize as XML file. So, will be throw error.