Use of TUniConnection.ExecSQL result

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hughespa
Posts: 81
Joined: Sat 23 Aug 2008 08:36
Location: W. Australia

Use of TUniConnection.ExecSQL result

Post by hughespa » Fri 29 Jan 2010 02:47

Hi,

This is using SQL Server 2008

If possible, how do I get the value returned using TUniConnection.ExecSQL ?

For example:

var
V: Variant;

V := UniConnection1.ExecSQL('SELECT COUNT(*) AS TOTAL_RECS FROM MY_TABLE', []);

V is always Null.

How do I get at the Result parameter mentioned in help?

ParamByName('Result') raises an exception since it doesn't exist but how do I specify an output parameter called RESULT in the above example query?

Thanks in advance.

Regards, Paul.

tobias_cd
Posts: 56
Joined: Thu 18 Dec 2008 22:10

Post by tobias_cd » Fri 29 Jan 2010 06:09

Hi Paul,

ExecSQL is only for DDL-Statements (UPDATE/INSERT/DELETE etc.), not SELECT's. You'll have to use TUniQuery for result sets.

Regards,
Tobias

hughespa
Posts: 81
Joined: Sat 23 Aug 2008 08:36
Location: W. Australia

Post by hughespa » Fri 29 Jan 2010 06:17

Thanks for that.

It looked like it might be useful to get a single value back rather than a complete result set.

Regards, Paul.

Post Reply