Last post Nov 01, 2010 09:40 AM by Martin_Honnen
Oct 31, 2010 12:54 PM|himchr|LINK
I am using XML in getting client data in 3-tier architecture, using XDocument in passing XML among layers.
But when I use it in inserting this XML in XDocument, it throws the following error:
No mapping exists from object type System.Xml.Linq.XDocument to a known managed provider native type.
I am using the following code, it throws the exception at the bold line:
public void DALInsertXML(XDocument x)
SqlConnection connection = new SqlConnection(connection1);
_command = new SqlCommand("spXML", connection);
_command.CommandType = CommandType.StoredProcedure;
_command.Connection = connection;
_command.Parameters.Add(new SqlParameter("@XML", x));
What is the reason of the above error,, how can I solve this problem?
Nov 01, 2010 09:40 AM|Martin_Honnen|LINK
What kind of SQL server data type does the parameter named "XML" of that stored procedure have?
Generally I think if you want to use LINQ to XML with MS SQL Server then you are better off to use LINQ to SQL together with LINQ to XML as that way I think you want call your stored procedure as a method of an object and that allows you to pass on a System.Xml.Linq.XElement
to a stored procedure that takes an "xml" T-SQL data type value.