Page 1 of 1

Use of TUniConnection.ExecSQL result

Posted: Fri 29 Jan 2010 02:47
by hughespa
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.

Posted: Fri 29 Jan 2010 06:09
by tobias_cd
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

Posted: Fri 29 Jan 2010 06:17
by hughespa
Thanks for that.

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

Regards, Paul.