存储过程以将xml doc插入sql server [英] stored procedure to insert xml doc in to sql server

查看:67
本文介绍了存储过程以将xml doc插入sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用.NET Framework 3.5.我在代码中创建了System.Xml.XmlDocument.我想执行一个存储过程,该过程将这个xml doc作为参数并将其插入到sql server数据库表中.列的数据类型为"xml"
我不知道如何在存储过程中执行此插入操作.如果我尝试插入它,就像插入普通字段一样,则会出现以下错误.

调用存储过程ins_xml时出错:无法将类型为"System.Xml.XmlDocument"的对象转换为类型为"System.Data.SqlClient.SqlParameter"."

请帮帮我..
预先感谢,
Vanathi

Hi
I''m working on .NET framework 3.5. I''ve created a System.Xml.XmlDocument in my code. I wanna execute a stored procedure that takes this xml doc as a parameter and inserts it into sql server database table. The datatype of the column is "xml"
I don''t know how to perform this insert operation within the stored procedure. I''m getting the following error if I try to insert it just like we insert a normal field.

"Error calling stored procedure ins_xml: Unable to cast object of type ''System.Xml.XmlDocument'' to type ''System.Data.SqlClient.SqlParameter''."

Please help me..
Thanks in advance,
Vanathi

推荐答案

您可以只使用xml的OuterXml属性
You can just use xml''s OuterXml property


希望对此提供帮助
http://msdn.microsoft.com/en-us/library/ms973817.aspx [ ^ ]

http://social.msdn.microsoft.com/Forums/zh/csharplanguage/thread/65b8bcc7-cd94-490a-9492-1d542df45439 [
hope help this
http://msdn.microsoft.com/en-us/library/ms973817.aspx[^]

http://social.msdn.microsoft.com/Forums/en/csharplanguage/thread/65b8bcc7-cd94-490a-9492-1d542df45439[^]


这篇关于存储过程以将xml doc插入sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆