Page 1 of 1

UniTransaction and ParameterCheck issue (Sql Server)

Posted: Fri 01 Aug 2014 05:44
by idem84
Hi, im having issues only when mixing UniTransaction and enabling ParameterCheck (using SqlServer and last dotconnect universal version of july 31 2014)
Exception: DeriveParameters requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
stacktrace at the end of post
Thanks in advance
sample code

var uniConnection = new UniConnection(MicroConnectionString);
uniConnection.Open();
var uniCommand = new UniCommand(); //uniConnection.CreateCommand();
UniTransaction uniTransaction;
//Start a local transaction
uniTransaction = uniConnection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted);
//Assign transaction object for a pending local transaction
uniCommand.Transaction = uniTransaction;
uniCommand.Connection = uniConnection;


try
{
uniCommand.CommandType = commandType;
uniCommand.CommandText = commandText;
uniCommand.CommandTimeout = commandTimeOut;

//if (commandType == CommandType.StoredProcedure)
// uniCommand.ParameterCheck = parameterCheck; // ***** Dont work with transaction (throws in ExecuteNonQuery below) using SqlServer as provider


foreach (var p in uniParameters) uniCommand.Parameters.Add(p);

var res = uniCommand.ExecuteNonQuery(); //Here throws if i enable parametercheck
uniCommand.Transaction.Commit();
UpdateParameters(parameters, uniParameters);
return res;
}
catch (Exception ex)
{
uniTransaction.Rollback();
throw new Exception(ex.Message + " Rollback executed!", ex.InnerException);
}
finally
{
uniConnection.Close();
}


StackTrace when exception throws if parametercheck=true
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.DeriveParameters()
at System.Data.SqlClient.SqlCommandBuilder.DeriveParameters(SqlCommand command)
at Devart.Data.Universal.SqlServerProvider.DeriveParameters(IDbCommand command)
at Devart.Data.Universal.UniCommand.DescribeProcedure(String name)
at Devart.Data.Universal.UniCommand.InternalPrepare(Boolean implicitPrepare, Int32 startRecord, Int32 maxRecords)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
at Devart.Common.DbCommandBase.ExecuteNonQuery()

Re: UniTransaction and ParameterCheck issue (Sql Server)

Posted: Tue 05 Aug 2014 10:25
by Pinturiccio
We have reproduced the issue. We will investigate it and post here about the results as soon as possible.

Re: UniTransaction and ParameterCheck issue (Sql Server)

Posted: Mon 11 Aug 2014 12:53
by Pinturiccio
We have fixed the bug with UniCommand.ParameterCheck property when using transaction while working with SQL Server. We will post here when the corresponding build of dotConnect Universal is available for download.

Re: UniTransaction and ParameterCheck issue (Sql Server)

Posted: Thu 14 Aug 2014 15:25
by Pinturiccio
New build of dotConnect Universal 3.50.722 is available for download now!
It can be downloaded from http://www.devart.com/dotconnect/univer ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=30169