PDA

View Full Version : خطا در ارسال پارامتر xml به sp؟



valentine093
دوشنبه 18 فروردین 1393, 13:59 عصر
با سلام و خسته نباشید.من برای ارسال سطرهای مختلف دیتاگرید به پایگاه داده از xml استفاده میکنم ولی در حین ارسال خطای زیر رخ میدهد.

The error description is 'Invalid at the top level of the document
Could not find prepared statement with handle 0
The XML parse error 0xc00ce556 occurred on line number 1, near the XML text "System.Data.SqlTypes.SqlXml"
The statement has been terminated

sp من در sql :






create proc asd_xml
@arr xml


as
DECLARE @handle INT
EXEC sp_xml_preparedocument @handle OUTPUT, @arr
insert into tbl_order_details
SELECT order_code,product_code,product_count
,Total_product_price
FROM OPENXML(@handle,'/product_info/order_code')--/product_code/product_count/Total_product_price')
with(order_code int '@order_code',
product_code int'@product_code',
product_count float '@product_count'
,Total_product_price decimal '@Total_product_price')
EXEC sp_xml_removedocument @handle




و فایل xml من در C#‎‎‎‎‎



<?xml version="1.0" encoding="utf-8"?>


<product_info>
<order_code>1</order_code>
<product_code>2</product_code>
<product_count>3</product_count>
<Total_product_price>1000</Total_product_price>
</product_info>



و ارسال پارامتر





SqlXml xml_doc = new SqlXml(new XmlTextReader("product_info.xml"));
scom = new SqlCommand("exec asd_xml '" + xml_doc + "'", base.open_connection());
scom.ExecuteNonQuery();


خیلی وقتم رو گرفته کمک کنین ممنون میشم.

Mahmoud.Afrad
پنج شنبه 21 فروردین 1393, 20:31 عصر
چه دلیل خاصی دارید که به صورت xml ارسال میکنید؟