Notifications

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
LHSoft
Posts: 104
Joined: Sat 18 Aug 2012 08:33

Notifications

Post by LHSoft » Sun 22 Mar 2015 11:47

Hello,

I have 4 tables on a form I want to set notifications.
All tables are set to read only.

If so, I can activate notifications for max. 2 of them, it does not matter what combination. If activating 3 or 4, i get an error message: Statement does not support notifications.

But if setting Read Only for all 4 tables to false, there is no problem.

So my question: is this a bug or what is the reason for the error Statement.

best regards
Hans

LHSoft
Posts: 104
Joined: Sat 18 Aug 2012 08:33

Re: Notifications

Post by LHSoft » Sun 22 Mar 2015 15:29

Hello,

and another question regarding notifications:
notification statements do not like table.refresh!

But sometimes it is necessary to ensure that table is up to date right now and cannot wait until notification will arrive.
Is there another way (then Table.Refresh)to tell the table to update data right NOW when notification statement is used?

best regards
Hans

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Notifications

Post by azyk » Thu 26 Mar 2015 13:13

The 'Statement does not support notifications' error message occurs when a SQL query in the dataset doesn't meet the MSDN requirements on using Notification ( https://msdn.microsoft.com/en-us/library/ms181122.aspx ). If you are using TMSTable as a dataset, then the SQL query will be generated in the following view:

Code: Select all

SELECT * FROM TABLE_NAME
and will be restricted by the following:
The statement may not use the asterisk (*) or table_name.* syntax to specify columns.

To solve the problem, do the following:
- replace the TMSTable component with the TMSQuery one for all the datasets, that use Notification;
- compose SQL queries manually for these datasets, so that they meet the above MSDN requirements. For example, instead of the a SQL query like:

Code: Select all

SELECT * FROM DEPT
compose such a query:

Code: Select all

SELECT DEPTNO, DNAME, LOC FROM dbo.DEPT

LHSoft
Posts: 104
Joined: Sat 18 Aug 2012 08:33

Re: Notifications

Post by LHSoft » Fri 27 Mar 2015 00:50

I do so already:
Form.Create: (Where TbLagBes is a TMSTable)
TbLagBes.SQL.Clear; SQLFields := '';
for i := 0 to TbLagBes.Fields.Count - 1 do
if i < TbLagBes.Fields.Count - 1 then
SQLFields := SQLFields + TbLagBes.Fields.FieldName + ','
else
SQLFields := SQLFields + TbLagBes.Fields.FieldName;
TbLagBes.SQL.Add('select ' + SQLFields + ' from dbo.MoLagBes');
TbLagBes.LockMode := lmPessimistic;
TbLagBes.ChangeNotification := DBM.StmKunCN;

Nofitication work fine as long as Tables are not set ReadOnly or there is no Table.refresh

Hans

azyk
Devart Team
Posts: 1057
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Notifications

Post by azyk » Fri 27 Mar 2015 08:12

We have tried to reproduce the problem according to your code, but it wasn't reproduced. Please try to compose a small test project demonstrating the problem. Include the test tables creating scripts and send them to andreyz*devart*com .

Post Reply