Page 1 of 1

DBX Error: Operation Not Supported

Posted: Mon 05 May 2008 08:19
by Lim Yong Seng
Hi,

Please kindly advise me, thanks in advance.


For "SELECT Cnt FROM Table1", SQLQuery1->RecordCount returned 0.

For "SELECT DISTINCT Cnt FROM Table1", SQLQuery1->RecordCount
returned this exception error:-

---------------------------
Debugger Exception Notification
---------------------------
Project ProjectMonitor.exe raised exception class EDatabaseError with message 'DBX Error: Operation Not Supported'. Process stopped. Use Step or Run to continue.


My system setup
---------------------
1. Borland C++ Builder Professional Ver 6.0
2. Microsoft SQL Server 2005
3. dbExpress driver for MS SQL Server (DbxSda version 4.25.8)


My database
----------------
1. Database name = DatabaseTest
2. Table name = Table1
3. Column Name = Cnt, Data Type = int, Allow Nulls = Yes
4. Table1 is empty.


My function
---------------
int TDataMod::SQLQueryOpen(void)
{
int count;

try
{
try
{
SQLQuery1->Close();
SQLQuery1->SQL->Clear();

//SQLQuery1->SQL->Add("SELECT Cnt FROM Table1");
SQLQuery1->SQL->Add("SELECT DISTINCT Cnt FROM Table1");
SQLQuery1->Open();

count = SQLQuery1->RecordCount;
}
catch(const Exception &E)
{
Application->MessageBox(E.Message.c_str(), "Debug", MB_OK);
}
}
__finally
{
SQLQuery1->Close();
}

return(count);
}


Thanks...Yong Seng

Posted: Mon 05 May 2008 12:29
by Antaeus
This behavior is defined in the SQLExpr.pas unit which is a part of C++Builder. If a query contains the DISTINCT keyword, the exception is raised.

DBX Error: Operation Not Supported

Posted: Tue 06 May 2008 01:06
by Lim Yong Seng
Hi Core Lab Team,

Thank you for answering my question.

Please kindly advise how am I able to get the record count if I need to use DISTINCT in my SQL query?

What is the property or function to call?

Thank you.

Have a nice day...Yong Seng

Posted: Tue 06 May 2008 07:16
by Antaeus
You should compose the query to request record count and execute it additionally: SELECT count( ...

DBX Error: Operation Not Supported

Posted: Tue 06 May 2008 08:39
by Lim Yong Seng
Hi Core Lab Team,

Thank you for your advises.
It works.

Thanks...Yong Seng