Cannot serialize the DataTable. DataTable name is not set.

Smith
Smith
None
2568 Points
74 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: 11667
Total Answered: 1
Total Marked As Answer: 1
Posted On: 31-Jul-2015 04:32

Share:   fb twitter linkedin
Answers
Brian
Brian
Moderator
2232 Points
14 Posts
         

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
 Log In to Chat