New to Telerik Reporting? Download free 30-day trial

SqlCommand Conversion Error

Environment

Product Progress® Telerik® Reporting
Version 18.2.24.924

Description

After updating to Telerik Reporting version 18.2.24.924, an error occurs when retrieving data using the SqlDataSource component with Stored Procedures when using a data provider different from the default System.Data.SqlClient.

For example, the below error indicates that the type Mysql.Data.MySqlClient.MySqlCommand cannot be converted to type System.Data.SqlClient.SqlCommand. This issue affects the execution of Stored Procedures, both with and without parameters.

Error Message

System.ArgumentException: Object of type 'MySql.Data.MySqlClient.MySqlCommand' cannot be converted to type 'System.Data.SqlClient.SqlCommand'.
   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Telerik.Reporting.Processing.Data.SqlProviderFactory.DeriveParameters(IDbCommand command)
   at Telerik.Reporting.Processing.Data.SqlCommandProvider.ResolveProcedure(IDbCommand command, SqlDataSourceParameterCollection parameters)
   at Telerik.Reporting.Processing.Data.SqlQueryProvider.CreateCommandCore(IDbConnection connection, Boolean evaluateParameters)
   at Telerik.Reporting.Processing.Data.SqlQueryProvider.CreateCommand(IDbConnection connection)
   at Telerik.Reporting.Processing.Data.SqlDataEnumerable.<GetEnumerator>d__2.MoveNext()
   at Telerik.Reporting.Processing.Data.LazyList`1.LazyListEnumerator.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Telerik.Reporting.Processing.Data.SeedDataAdapter.Execute(IEnumerable`1 data)
   at Telerik.Reporting.Processing.Data.ResultSetAdapter.Execute(IEnumerable`1 data)
   at Telerik.Reporting.Processing.Data.MultidimentionalDataProvider.Execute(MultidimensionalQuery query)
   at Telerik.Reporting.Processing.DataItemResolveDataAlgorithm.GetDataCore(IDataSource dataSource, MultidimensionalQuery query, IServiceProvider serviceProvider, EvalObject expressionContext, IProcessingContext processingContext)
   at Telerik.Reporting.Processing.Report.GetDataCore(IDataSource dataSource, MultidimensionalQuery query)
   at Telerik.Reporting.Processing.DataItemResolveDataAlgorithm.ResolveData(String processingId, InMemoryState inMemoryState, MultidimensionalQuery query, Func`1 getDataCore, EvalObject expressionContext)
   at Telerik.Reporting.Processing.Report.ResolveData()
   at Telerik.Reporting.Processing.Report.ProcessItemCore()
   at Telerik.Reporting.Processing.Report.ProcessItem()
   at Telerik.Reporting.Processing.ReportItemBase.ProcessElement()
   at Telerik.Reporting.Processing.ProcessingElement.Process(IDataMember dataContext)

Cause

The issue is caused by changes related to the Type Restrictions introduced with the Telerik Reporting 2024 Q3(18.2.24.924) release.

Inline SQL queries work as expected, but Stored Procedures throw a conversion error for any data provider other than System.Data.SqlClient.

Workaround

Manually invoking the Stored Procedures works for both scenarios - with and without parameters. The syntax for invoking a Stored Procedure depends on the data provider and the database:

  • MySQL

    CALL Stored_Procedure;
    
  • Oracle

    EXECUTE Stored_Procedure;
    
  • PostgreSQL

    CALL Stored_Procedure();
    
  • MSSQL

    EXEC Stored_Procedure;
    

See Also

In this article