Prepare - The data types nvarchar and sql_variant are incompatible in the add operator.

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
AndreasNeef
Posts: 1
Joined: Mon 22 Sep 2014 09:07

Prepare - The data types nvarchar and sql_variant are incompatible in the add operator.

Post by AndreasNeef » Mon 22 Sep 2014 09:49

Hello!

We're using odac in Delphi for years and we're now extending our software to use sdac 6.10.21 and odac 9.3.10 at the same time. The following code raises an Error in sdac, when executing the prepare.

Code: Select all

qry: TMSQuery;
...
qry.SQL.Text := 'SELECT name FROM sys.objects WHERE name = :sName And type_desc LIKE ''%'' + :sTyp + ''%''';
qry.Prepare;
...
When we put the '%' into the parameter instead of the sql-statement, it works fine. In the forum we've read about defining the parameters datatype before preparing. Is there any other solution for our problem? In odac this code sequences works perfect (with || instead of +).

Yours sincerely

Andreas

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Prepare - The data types nvarchar and sql_variant are incompatible in the add operator.

Post by azyk » Wed 24 Sep 2014 12:20

In you case, this error is returned by SQL Server, and we can't affect this behavior. Have a look at the discussion at MSDN for alternative solutions for this problem: http://social.msdn.microsoft.com/Forums ... ngservices

Post Reply