Why returning dataset or data table from WCF service is not a good practice? What are the Alternatives?

前端 未结 3 1666
萌比男神i
萌比男神i 2020-12-06 05:38

I am working on University Management System on which I am using a WCF service and in the service I am using DataTables and DataSets for getting data from database and datab

3条回答
  •  甜味超标
    2020-12-06 06:20

    I am using DataTable in my WCF application, but was getting an error. This is how I fixed the error.

    When returning a DataTable from a web service in WCF to windows form application. I was getting this exception.

    System.ServiceModel.CommunicationException: 'An error occurred while receiving the HTTP response to http://localhost:52968/MunerahService1.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.'

    It happened any time I tried to retrieve a DataTable

    To fix the exception I needed to give the DataTable a name.

    code with the error

     tab = new DataTable(); 
    

    Fixed code to remove the excption

     tab = new DataTable("Doctor_info");
    

提交回复
热议问题