Cannot serialize the DataTable. DataTable name is not set.

Smith
Smith
Participant
360 Points
110 Posts

Hi,

 I am using a webservice in my web-application. Webservice is having 2 methods one is working fine means my webservice is ok, but when I use the second service,through which I am fetching a datatabe, it shows error

System.Web.Services. Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set.

below is my webservice's code for fetching.

    [WebMethod]
    public DataTable Select_Employee_By_Sno(string Emp_Code)
    {
        Business_Logic bl = new Business_Logic();
        DataTable dt = new DataTable();
        dt= bl.Select_Employee_By_Sno(Emp_Code);
        return dt;
    }
Views: 8298
Total Answered: 1
Total Marked As Answer: 1
Posted On: 31-Jul-2015 04:32

Share:   fb twitter linkedin
Answers
Brian
Brian
Participant
536 Points
73 Posts
Marked as answer      

Hi smith,

Use TableName property of DataTable as:

[WebMethod] 
public DataTable Select_Employee_By_Sno(string Emp_Code)
{
Business_Logic bl =new Business_Logic();
 
DataTable dt = new DataTable();
dt.TableName ="somename";
dt = bl.Select_Employee_By_Sno(Emp_Code);
 
return dt;
}

 

Posted On: 01-Aug-2015 23:27
banner

Blog

Active User (0)

No Active User!
 Log In to Chat