R
rgelfand
Guest
I am getting an exception, see below. I am sending a pretty large xml string to a procedure.
namespace WBpi.DSData
{
public static class DatabaseConnector
{
public static XmlNode DoAction(string p_action, string p_connectionString, XmlNode p_XmlParams)
{
string stringResult = null;
string v_AppPath = HttpContext.Current.Request.ApplicationPath;
using (SqlConnection connection = new SqlConnection(p_connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(Settings.Default.InteropProc, connection))
{
command.CommandTimeout = Settings.Default.SqlCommandTimeout;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Action", p_action));
command.Parameters.Add(new SqlParameter("@XmlParams", p_XmlParams.OuterXml));
SqlParameter XmlResult = new SqlParameter("@XmlResult", stringResult);
XmlResult.DbType = DbType.AnsiString;
XmlResult.Size = -1;
XmlResult.Direction = ParameterDirection.Output;
command.Parameters.Add(XmlResult);
command.ExecuteNonQuery();
stringResult = command.Parameters["@XmlResult"].Value.ToString();
}
connection.Close();
}
//cast stringResult to XmlNode
XmlDocument xmlDBResult = new XmlDocument();
xmlDBResult.LoadXml(stringResult);
XmlNode xmlObject = xmlDBResult.DocumentElement;
return xmlObject;
}
}
}
System.Exception: Creating MTS failed ---> System.Exception: Creating MTS failed ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) at System.Text.EncodingNLS.GetString(Byte[] bytes, Int32 index, Int32 count)
at System.Data.SqlClient.TdsParserStateObject.TryReadStringWithEncoding(Int32 length, Encoding encoding, Boolean isPlp, String& value)
at System.Data.SqlClient.TdsParser.TryReadSqlStringValue(SqlBuffer value, Byte type, Int32 length, Encoding encoding, Boolean isPlp, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj, SqlCommandColumnEncryptionSetting columnEncryptionOverride, String columnName)
at System.Data.SqlClient.TdsParser.TryProcessReturnValue(Int32 length, TdsParserStateObject stateObj, SqlReturnValue& returnValue, SqlCommandColumnEncryptionSetting columnEncryptionSetting)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int3
Continue reading...
namespace WBpi.DSData
{
public static class DatabaseConnector
{
public static XmlNode DoAction(string p_action, string p_connectionString, XmlNode p_XmlParams)
{
string stringResult = null;
string v_AppPath = HttpContext.Current.Request.ApplicationPath;
using (SqlConnection connection = new SqlConnection(p_connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand(Settings.Default.InteropProc, connection))
{
command.CommandTimeout = Settings.Default.SqlCommandTimeout;
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Action", p_action));
command.Parameters.Add(new SqlParameter("@XmlParams", p_XmlParams.OuterXml));
SqlParameter XmlResult = new SqlParameter("@XmlResult", stringResult);
XmlResult.DbType = DbType.AnsiString;
XmlResult.Size = -1;
XmlResult.Direction = ParameterDirection.Output;
command.Parameters.Add(XmlResult);
command.ExecuteNonQuery();
stringResult = command.Parameters["@XmlResult"].Value.ToString();
}
connection.Close();
}
//cast stringResult to XmlNode
XmlDocument xmlDBResult = new XmlDocument();
xmlDBResult.LoadXml(stringResult);
XmlNode xmlObject = xmlDBResult.DocumentElement;
return xmlObject;
}
}
}
System.Exception: Creating MTS failed ---> System.Exception: Creating MTS failed ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding) at System.Text.EncodingNLS.GetString(Byte[] bytes, Int32 index, Int32 count)
at System.Data.SqlClient.TdsParserStateObject.TryReadStringWithEncoding(Int32 length, Encoding encoding, Boolean isPlp, String& value)
at System.Data.SqlClient.TdsParser.TryReadSqlStringValue(SqlBuffer value, Byte type, Int32 length, Encoding encoding, Boolean isPlp, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj, SqlCommandColumnEncryptionSetting columnEncryptionOverride, String columnName)
at System.Data.SqlClient.TdsParser.TryProcessReturnValue(Int32 length, TdsParserStateObject stateObj, SqlReturnValue& returnValue, SqlCommandColumnEncryptionSetting columnEncryptionSetting)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int3
Continue reading...