Subject IBEvents - how works.
Author Gerson Machado - Yahoo
My scenario: FB 1.5 (4481) + D7 + IBX 7.08
What was defined: IBDatabase1, IBTransaction1, IBQuery1, IBUpdateSQL1,
IBEvents1, DataSource1, cxGrid1.
What is happened: I defined a POST_EVENT in my table (access by
IBQuery1) and defined the same name to event um IBEvents1, but I don’t
receive the event.

See my source:

unit unEventos1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses,
cxControls,
cxGridCustomView, cxGrid, IBEvents, IBCustomDataSet, IBUpdateSQL,
IBDatabase, IBQuery, StdCtrls, ComCtrls, cxNavigator, cxDBNavigator,
cxMaskEdit, cxDBEdit, cxContainer, cxTextEdit, LMDCustomButton,
LMDButton;

type
TForm1 = class(TForm)
DataSource1: TDataSource;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxGrid1DBTableView1DBColumn1: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn2: TcxGridDBColumn;
cxGrid1DBTableView1DBColumn3: TcxGridDBColumn;
cxDBTextEdit1: TcxDBTextEdit;
cxDBTextEdit2: TcxDBTextEdit;
cxDBMaskEdit1: TcxDBMaskEdit;
cxDBNavigator1: TcxDBNavigator;
LMDButton1: TLMDButton;
IBDatabase1: TIBDatabase;
IBTransaction1: TIBTransaction;
IBQuery1: TIBQuery;
IBQuery1REGID: TIntegerField;
IBQuery1NOME: TIBStringField;
IBQuery1VALOR: TIBBCDField;
IBUpdateSQL1: TIBUpdateSQL;
IBEvents1: TIBEvents;
procedure IBEvents1EventAlert(Sender: TObject; EventName: String;
EventCount: Integer; var CancelAlerts: Boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure IBEvents1Error(Sender: TObject; ErrorCode: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IBEvents1EventAlert(Sender: TObject; EventName: String;
EventCount: Integer; var CancelAlerts: Boolean);
begin
MessageDlg('Delphi message: ' + EventName + ' event occured',
mtInformation, mbOKCancel, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
IBDatabase1.Connected := True;
IBTransaction1.Active := True;
IBEvents1.Registered := True;
IBQuery1.Active := true;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
// IBQuery1.Active := false;
// IBEvents1.Registered := false;
// IBTransaction1.Active := false;
// IBDatabase1.Connected := false;
end;

procedure TForm1.IBEvents1Error(Sender: TObject; ErrorCode: Integer);
begin
MessageDlg('Erro de evento: ' + intToStr(ErrorCode) + ' ',
mtInformation, mbOKCancel, 0);
end;

end.

------------------ end source.

My Form:

object Form1: TForm1
Left = 192
Top = 114
Width = 586
Height = 257
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
PixelsPerInch = 96
TextHeight = 13
object cxGrid1: TcxGrid
Left = 112
Top = 16
Width = 425
Height = 105
TabOrder = 0
object cxGrid1DBTableView1: TcxGridDBTableView
DataController.DataSource = DataSource1
DataController.Summary.DefaultGroupSummaryItems = <>
DataController.Summary.FooterSummaryItems = <>
DataController.Summary.SummaryGroups = <>
NavigatorButtons.ConfirmDelete = False
object cxGrid1DBTableView1DBColumn1: TcxGridDBColumn
DataBinding.FieldName = 'REGID'
end
object cxGrid1DBTableView1DBColumn2: TcxGridDBColumn
DataBinding.FieldName = 'NOME'
end
object cxGrid1DBTableView1DBColumn3: TcxGridDBColumn
DataBinding.FieldName = 'VALOR'
end
end
object cxGrid1Level1: TcxGridLevel
GridView = cxGrid1DBTableView1
end
end
object cxDBTextEdit1: TcxDBTextEdit
Left = 112
Top = 128
Width = 41
Height = 21
DataBinding.DataField = 'REGID'
DataBinding.DataSource = DataSource1
TabOrder = 1
end
object cxDBTextEdit2: TcxDBTextEdit
Left = 160
Top = 128
Width = 257
Height = 21
DataBinding.DataField = 'NOME'
DataBinding.DataSource = DataSource1
TabOrder = 2
end
object cxDBMaskEdit1: TcxDBMaskEdit
Left = 424
Top = 128
Width = 121
Height = 21
DataBinding.DataField = 'VALOR'
DataBinding.DataSource = DataSource1
TabOrder = 3
end
object cxDBNavigator1: TcxDBNavigator
Left = 112
Top = 160
Width = 225
Height = 25
DataSource = DataSource1
TabOrder = 4
end
object LMDButton1: TLMDButton
Left = 344
Top = 160
Width = 75
Height = 25
Caption = 'LMDButton1'
TabOrder = 5
end
object DataSource1: TDataSource
DataSet = IBQuery1
Left = 16
Top = 80
end
object IBDatabase1: TIBDatabase
Connected = True
DatabaseName = '192.168.12.5:EMPLOYEE'
Params.Strings = (
'user_name=SYSDBA'
'password=masterkey')
LoginPrompt = False
Left = 16
Top = 8
end
object IBTransaction1: TIBTransaction
Active = True
DefaultDatabase = IBDatabase1
Params.Strings = (
'read_committed'
'rec_version'
'nowait')
Left = 48
Top = 24
end
object IBQuery1: TIBQuery
Database = IBDatabase1
Transaction = IBTransaction1
SQL.Strings = (
'select * from TBTESTE1')
UpdateObject = IBUpdateSQL1
Left = 16
Top = 40
object IBQuery1REGID: TIntegerField
FieldName = 'REGID'
Origin = '"TBTESTE1"."REGID"'
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
Required = True
end
object IBQuery1NOME: TIBStringField
FieldName = 'NOME'
Origin = '"TBTESTE1"."NOME"'
Size = 30
end
object IBQuery1VALOR: TIBBCDField
FieldName = 'VALOR'
Origin = '"TBTESTE1"."VALOR"'
Size = 2
end
end
object IBUpdateSQL1: TIBUpdateSQL
RefreshSQL.Strings = (
'Select '
' REGID,'
' NOME,'
' VALOR'
'from TBTESTE1 '
'where'
' REGID = :REGID')
ModifySQL.Strings = (
'update TBTESTE1'
'set'
' NOME = :NOME,'
' REGID = :REGID,'
' VALOR = :VALOR'
'where'
' REGID = :OLD_REGID')
InsertSQL.Strings = (
'insert into TBTESTE1'
' (NOME, REGID, VALOR)'
'values'
' (:NOME, :REGID, :VALOR)')
DeleteSQL.Strings = (
'delete from TBTESTE1'
'where'
' REGID = :OLD_REGID')
Left = 48
Top = 56
end
object IBEvents1: TIBEvents
AutoRegister = False
Database = IBDatabase1
Events.Strings = (
'evento2')
Registered = False
Left = 48
Top = 96
end
end



Cordiais saudações,

Gerson Machado
Senior System Engineer
AllCorp Tecnologia da Informação Ltda.
HYPERLINK "http://www.allcorp.com.br"www.allcorp.com.br




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.744 / Virus Database: 496 - Release Date: 24/8/2004



[Non-text portions of this message have been removed]