I have a Delphi project. To connect to MSSQL I use ADO. I decided to see, what kind of alternative variants were and I looked at SDAC. Unfortunately, I find the problem which I don't know how to manage.
I have a Query: TMSQuery. There is a query inside:
select Val1, Val2 from dbo.MyFunction(:Param1, :Param2, :Param3) order by Val1
When I try to call Query.Prepare I get Exception with error message about syntax error or illegal cross of access right. Everything works in ADO correctly. Couldn't I hear comments
of specialist about my problem?
Error in Prepare SQL query with params in UDF function call
This is OLE DB problem.
To workaround this problem set parameters information before calling Prepare method.
For example:
MSQuery1.SQL.Text := 'select Val1, Val2 from dbo.MyFunction(:Param1,:Param2, :Param3) order by Val1';
MSQuery1.ParamByName('Param1').AsInteger := 10;
MSQuery1.ParamByName('Param2').AsInteger := 20;
MSQuery1.ParamByName('Param3').AsInteger := 30;
MSQuery1.Prepare;
Please download the latest SDAC version to use this workaround.
To workaround this problem set parameters information before calling Prepare method.
For example:
MSQuery1.SQL.Text := 'select Val1, Val2 from dbo.MyFunction(:Param1,:Param2, :Param3) order by Val1';
MSQuery1.ParamByName('Param1').AsInteger := 10;
MSQuery1.ParamByName('Param2').AsInteger := 20;
MSQuery1.ParamByName('Param3').AsInteger := 30;
MSQuery1.Prepare;
Please download the latest SDAC version to use this workaround.