I have a stored procedure which returns the XML as an output parameter. When I call the procedure from a C# application, it generates ArgumentOutOfRangeException. Refer below given exception stacktrace. The C# application uses Microsoft.Data.SqlClient 6.1.3 NuGet package for database operations. To regenerate the issue, refer below given sample stored procedure and its execution using C#.
System.ArgumentOutOfRangeException: The SqlDbType enumeration value, 0, is invalid. (Parameter 'SqlDbType')
at Microsoft.Data.SqlClient.MetaType.GetSqlDataType(Int32 tdsType, UInt32 userType, Int32 length)
at Microsoft.Data.SqlClient.TdsParser.TryProcessReturnValue(Int32 length, TdsParserStateObject stateObj, SqlReturnValue& returnValue, SqlCommandColumnEncryptionSetting columnEncryptionSetting)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()
at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader()
at BabelfishDiag.Program.XmlOutputTest() in C:\PoC\BabelfishDiag\BabelfishDiag\Program.cs:line 159
What happened?
I have a stored procedure which returns the XML as an output parameter. When I call the procedure from a C# application, it generates
ArgumentOutOfRangeException. Refer below given exception stacktrace. The C# application usesMicrosoft.Data.SqlClient6.1.3 NuGet package for database operations. To regenerate the issue, refer below given sample stored procedure and its execution using C#.Stored procedure
CREATE PROCEDURE [dbo].[spu_XmlOutputTest] @UsersXml XML Output AS BEGIN SET NOCOUNT ON SET @UsersXml = N'<root><p n="EventAndAuditUser" v="Foo System Agent" /><p n="EventAndAuditUser" v="Bar" /></root>' ENDStored procedure execution using C#
Exception
Version
BABEL_5_X_DEV (Default)
Extension
babelfishpg_tds
Which flavor of Linux are you using when you see the bug?
Ubuntu (Default)
Relevant log output
Code of Conduct