Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 18th, 2006, 03:07 AM
Authorized User
 
Join Date: Sep 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default SqlDbType.Xml Output Parameter needs a size - Why?

Hi Guys,

I'm calling a stored procedure from my VB.NET application and it passes the following SQLParameters.

sdiParameters(0) = New SqlParameter("@RequestXML", RequestXML.InnerXml)
sdiParameters(0).SqlDbType = SqlDbType.Xml
sdiParameters(0).Size = RequestXML.InnerXml.Length
sdiParameters(1) = New SqlParameter("@UserID", UserID)
sdiParameters(1).SqlDbType = SqlDbType.Int
sdiParameters(2) = New SqlParameter("@FailureMessage", System.DBNull.Value)
sdiParameters(2).Direction = ParameterDirection.InputOutput
sdiParameters(2).SqlDbType = SqlDbType.NVarChar
sdiParameters(2).Size = 255
sdiParameters(3) = New SqlParameter("@SessionID", System.DBNull.Value)
sdiParameters(3).Direction = ParameterDirection.InputOutput
sdiParameters(3).SqlDbType = SqlDbType.Int
sdiParameters(4) = New SqlParameter("@ProcessXML", System.DBNull.Value)
sdiParameters(4).Direction = ParameterDirection.InputOutput
sdiParameters(4).SqlDbType = SqlDbType.Xml
sdiParameters(4).Size = 1 ' * * * Why do I need to specify this? * * *
sdiParameters(5) = New SqlParameter("@RETURN_VALUE", System.DBNull.Value)
sdiParameters(5).Direction = ParameterDirection.ReturnValue

sdiParameters(4) is an Output parameter and the XML will be loaded into a XMLDocument after the SP executes.

I get the following error "System.InvalidOperationException: String[4]: the Size property has an invalid size of 0." if I do not specify the length of sdiParameters(4). As it is returned from the SP I do not know what the length will be before the SP executes.

If I set the size to 1, it works and executes successfully.

Any ideas why?

Cheers,

Francis

 
Old January 28th, 2008, 08:28 PM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It gave me good idea on XML as parameters.

How to set the value to the parameter which is SqlDbType.XML type.

I need to send an XML file as parameter to SQL Stored Procedure and save the data of XML file in the SQL Server Database.

Can you please provide me with the sample code of assigning XML file to the Stored Procedure and in the Stored Procedure of how to navigate thru XML file and save in the table of SQL Server database.

Thanks in Advance
prabhakar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing Output Parameter Value GailCG SQL Server 2005 1 November 19th, 2008 08:52 AM
output parameter SKhna ASP.NET 2.0 Basics 3 February 25th, 2008 10:58 AM
How to return an output parameter dyaneshwaran SQL Language 0 January 12th, 2006 05:29 AM
Output Size aspadda Excel VBA 2 April 3rd, 2004 06:42 PM
web service parameter size androger .NET Web Services 2 November 19th, 2003 01:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.