# Error executing query

**URL:** <https://forum.servoy.com/t/error-executing-query/19399>\
**Category:** Classic Servoy\
**Created:** [August 31, 2017, 1:26pm UTC](https://forum.servoy.com/t/error-executing-query/19399 "2017-08-31T13:26:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![developers10](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@developers10](https://forum.servoy.com/u/developers10)\
**Post date:** [August 31, 2017, 1:26pm UTC](https://forum.servoy.com/t/error-executing-query/19399/1 "2017-08-31T13:26:18Z")

</div>

Hi,

We changed from the net.sourceforge.jtds.jdbc.Driver to the com.microsoft.sqlserver.jdbc.SQLServerDriver  
Since then, we get an arror when executing the databaseManager.getDataSetByQuery  
Error :

```auto
The statement did not return a result set.

```

When executing the entire same query directly in Sql Server Management studio, one record is returned.

When googling this, I get several posts stating we should append

```auto
allowMultiQueries=true

```

to the connectionstring. Which I tried but no solution.  
Could it be that this property is not passed by Servoy?  
Or what is the solution to this problem?  
FYI: ```  
SelectMethod=cursor

```is

The query is complex but Sql nonetheless and worked with the previous driver :

```

DECLARE @intDocHandle INT;  
DECLARE @xmlString VARCHAR(max);

SET @xmlString = ‘\<key ID=’‘0FD2AC09-9856-41B8-B5B6-0573775E5CE5’‘/\> ’;

EXEC sp\_xml\_preparedocument @intDocHandle OUTPUT  
,@xmlString;

IF OBJECT\_ID(‘tempdb…#temp\_801873526’) IS NOT NULL  
DROP TABLE #temp\_801873526;

CREATE TABLE #temp\_801873526 (ID UNIQUEIDENTIFIER);

INSERT INTO #temp\_801873526  
SELECT \*  
FROM OPENXML(@intDocHandle, ‘/root/key’) WITH (ID UNIQUEIDENTIFIER);

DECLARE @query AS NVARCHAR(max);  
DECLARE @column\_names AS NVARCHAR(max);

SELECT @column\_names = ISNULL(@column\_names + ‘,’, ‘’) + QUOTENAME(pde.tablename + ‘\_’ + pde.fieldname)  
FROM price\_rule  
INNER JOIN price\_dependency pde ON pde.price\_rule\_id = price\_rule.price\_rule\_id  
INNER JOIN #temp\_801873526 ON pde.price\_rule\_id = #temp\_801873526.ID  
ORDER BY pde.sequence\_nr;

IF @column\_names IS NULL  
OR LEN(@column\_names) = 0  
SET @query = N’select pri.valid\_from,pri.valid\_till,pri.result\_value,pri.free\_quantity, pri.price\_item\_id from price\_item pri where 1 = 0; ‘;  
ELSE  
SET @query = N’select ’ + @column\_names +  
‘,pvt.price\_rule\_type,pvt.return\_result\_type,pvt.price\_rule\_code,pvt.price\_item\_id,pvt.price\_rule\_id,pvt.uplift\_helper, pvt.result\_value,pvt.result\_value\_incl,pvt.currency\_id,pvt.valid\_from,valid\_till, pvt.free\_quantity, pvt.flag\_default, pvt.flag\_fixed\_price, pvt.flag\_free,pvt.formula\_id,pvt.valid\_when\_formula\_id, pvt.max\_amount,pvt.result\_value\_extra\_qty,pvt.result\_value\_per, pvt.result\_value\_per\_unit\_id,pvt.target\_margin,pvt.current\_margin ,pvt.formula\_code, pvt.valid\_when\_formula\_code,pvt.currency\_code, pvt.result\_value\_per\_unit\_code FROM ( select pru.price\_rule\_type,pru.return\_result\_type,pru.price\_rule\_code,pri.price\_item\_id,pri.price\_rule\_id, cast(0 as numeric(18,6)) as uplift\_helper,pri.valid\_from,pri.valid\_till, pri.result\_value,pri.result\_value\_incl,pri.free\_quantity,pri.currency\_id, pri.flag\_default, pri.flag\_fixed\_price, pri.flag\_free, pri.formula\_id,pri.valid\_when\_formula\_id, pri.max\_amount,pri.result\_value\_extra\_qty,pri.result\_value\_per, pri.result\_value\_per\_unit\_id, concat(pde.tablename,’’\_‘’,pde.fieldname) as tablefield, target\_margin,cast(0 as numeric(18,6)) as current\_margin ,cast(space(1) as nvarchar(50)) as formula\_code,cast(space(1) as nvarchar(50)) as valid\_when\_formula\_code, isnull(currency.currency\_code,space(10)) as currency\_code, isnull(au.articleunit\_code,‘’‘’) as result\_value\_per\_unit\_code, case when pva.price\_value\_id is null and pde.fieldtype=‘‘UUID’’ then cast(‘‘00000000-0000-0000-0000-000000000000’’ as nvarchar(64)) when pva.price\_value\_id is null then cast(‘’‘’ as nvarchar(64)) when pde.fieldtype=‘‘BOOL’’ then cast(pva.value\_boolean as nvarchar(64)) when pde.fieldtype=‘‘DATE’’ then convert(nvarchar(64),pva.value\_datetime,103) when pde.fieldtype=‘‘INTEGER’’ then cast(pva.value\_integer as nvarchar(64)) when pde.fieldtype=‘‘NUMBER’’ then cast(pva.value\_number as nvarchar(64)) when pde.fieldtype=‘‘UUID’’ then cast(pva.value\_uuid as nvarchar(64)) else cast(pva.value\_text as nvarchar(64)) end as column\_value from price\_dependency pde inner join #temp\_801873526 on pde.price\_rule\_id = #temp\_801873526.ID inner join price\_rule pru on pru.price\_rule\_id = #temp\_801873526.ID inner join price\_item pri on pri.price\_rule\_id = #temp\_801873526.ID left join currency on pri.currency\_id = currency.currency\_id left join articleunits au on pri.result\_value\_per\_unit\_id = au.articleunit\_id inner join price\_value pva on pde.price\_dependency\_id = pva.price\_dependency\_id and pva.price\_item\_id = pri.price\_item\_id ) as data pivot ( max(column\_value) for tablefield in (’  
+ @column\_names + ‘) ) as pvt ;’;

EXEC sp\_executesql @query;

IF OBJECT\_ID(‘tempdb…#temp\_801873526’) IS NOT NULL  
DROP TABLE #temp\_801873526;

```auto

```
