DBX Error: Operation Not Supported

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Lim Yong Seng
Posts: 6
Joined: Mon 05 May 2008 02:08

DBX Error: Operation Not Supported

Post by Lim Yong Seng » Mon 05 May 2008 08:19

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 05 May 2008 12:29

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.

Lim Yong Seng
Posts: 6
Joined: Mon 05 May 2008 02:08

DBX Error: Operation Not Supported

Post by Lim Yong Seng » Tue 06 May 2008 01:06

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

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 06 May 2008 07:16

You should compose the query to request record count and execute it additionally: SELECT count( ...

Lim Yong Seng
Posts: 6
Joined: Mon 05 May 2008 02:08

DBX Error: Operation Not Supported

Post by Lim Yong Seng » Tue 06 May 2008 08:39

Hi Core Lab Team,

Thank you for your advises.
It works.

Thanks...Yong Seng

Post Reply