Error while serializing the body of the message: "An error occurred while generating the XML document.". For more information, see InnerException. Or no external reference to the object instance

My situation here is that after querying the data from the database, I need to perform some operations on the table and assign it to datagirdview, but an error occurs when the data is retrieved from the table and the service is called: "An error occurred while serializing the body of the message:" An error occurred while generating the XML document. ". For more information, see InnerException. Or no external reference to an instance of the object"
Next is the solution.
DataSet ds = new DataSet();
DataTable dtCopy=Dtb_KYData.Copy();
ds.Tables.Add(dtCopy);
Dtb_KYData.Rows.Clear();
Dtb_KYData = ds.Tables[0];
where Dtb_KYData is a database query Come out for the revised data sheet.
I copied the table structure and data of this table to another table. Then clear it and re-assign it, the function is completed

Guess you like

Origin blog.csdn.net/hello_mr_anan/article/details/82181993