Subject Re: [IBO] TIBOQuery and TIB_Query are completely different?
Author consultor_cys
Here it goes:

---------------------------------------------------------------------
IBOTEST.DPR
---------------------------------------------------------------------
program IBOTest;

uses
Forms,
Main in 'Main.pas' {MainForm};

{$R *.RES}

begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.


---------------------------------------------------------------------
MAIN.PAS
---------------------------------------------------------------------

unit Main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls, IB_Components, IBODataset, Db, Grids, DBGrids;

type
TMainForm = class(TForm)
IBODatabase: TIBODatabase;
qIBOQuery: TIBOQuery;
IBOTransaction: TIBOTransaction;
btnConnect: TButton;
mSQL: TMemo;
Label2: TLabel;
btnExecSQL: TButton;
DataSource: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
qExecSQL: TIBOQuery;
btnOpen: TButton;
procedure btnConnectClick(Sender: TObject);
procedure btnExecSQLClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure btnOpenClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
MainForm: TMainForm;

implementation

{$R *.DFM}

procedure TMainForm.btnConnectClick(Sender: TObject);
begin
with IBODatabase do begin
if Connected then begin
Disconnect;
end;
try
Connect;
except
ShowMessage('Error connecting.');
exit;
end;
ShowMessage('Connection was successful.');
end;
end;

procedure TMainForm.btnExecSQLClick(Sender: TObject);
begin
if not IBODatabase.Connected then begin
btnConnectClick(NIL);
end;

with qExecSQL do begin
SQL.Text := mSQL.Lines.Text;
try
ExecSQL;
except
ShowMessage('Error creating table.');
exit;
end;

IBOTransaction.Commit;

ShowMessage('SQL Execution was successful.');
end;
end;

procedure TMainForm.Button1Click(Sender: TObject);
var
iCounter : integer;
begin
if not qIBOQuery.Active then begin
btnOpenClick(NIL);
end;

with qIBOQuery do begin
if not Active then begin
btnOpenClick(NIL);
end;
for iCounter := 1 to 10 do begin
Insert;
FieldByName('CODIGO_DIREITO').Value := iCounter;
FieldByName('ORDEM').Value := 'AAA-'+IntToStr(iCounter);
FieldByName('NIVEL').Value := 'BBB-'+IntToStr(iCounter);
FieldByName('DESCRICAO').Value := 'CCC-'+IntToStr(iCounter);

Post;
end;
end;

IBOTransaction.Commit;
end;

procedure TMainForm.btnOpenClick(Sender: TObject);
begin
if not IBODatabase.Connected then begin
btnConnectClick(NIL);
end;

with qIBOQuery do begin
if not Active then begin
Open;
end;
end;
end;

end.

---------------------------------------------------------------------
MAIN.DFM
---------------------------------------------------------------------

object MainForm: TMainForm
Left = 163
Top = 152
Width = 549
Height = 322
Caption = 'IBOTest'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 96
TextHeight = 13
object Label2: TLabel
Left = 20
Top = 11
Width = 21
Height = 13
Caption = 'SQL'
end
object btnConnect: TButton
Left = 457
Top = 23
Width = 75
Height = 25
Caption = 'Connect'
TabOrder = 0
OnClick = btnConnectClick
end
object mSQL: TMemo
Left = 16
Top = 24
Width = 433
Height = 122
Lines.Strings = (
'CREATE TABLE L_DIREITO ('
' codigo_direito DECIMAL(18,0) NOT NULL'
', ordem DECIMAL(18,0)'
', nivel VARCHAR(2)'
', descricao VARCHAR(100)'
', nome_modulo VARCHAR(100)'
', CONSTRAINT PK_L_DIREITO PRIMARY KEY (codigo_direito)'
');')
TabOrder = 1
end
object btnExecSQL: TButton
Left = 457
Top = 55
Width = 75
Height = 25
Caption = 'ExecSQL'
TabOrder = 2
OnClick = btnExecSQLClick
end
object DBGrid1: TDBGrid
Left = 16
Top = 160
Width = 433
Height = 120
DataSource = DataSource
TabOrder = 3
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 457
Top = 191
Width = 75
Height = 25
Caption = 'Add Records'
TabOrder = 4
OnClick = Button1Click
end
object btnOpen: TButton
Left = 457
Top = 159
Width = 75
Height = 25
Caption = 'Open'
TabOrder = 5
OnClick = btnOpenClick
end
object IBODatabase: TIBODatabase
LoginPrompt = True
Params.Strings = (
'SERVER=192.168.1.103'
'PATH=d:\dados\dat\fb\wlaud\wlaud.gdb'
'PROTOCOL=TCP/IP'
'USER NAME=SYSDBA')
Left = 376
Top = 32
SavedPassword = '.JuMbLe.01.432B0639073E0E4B49'
end
object qIBOQuery: TIBOQuery
Params = <>
DatabaseName = '192.168.1.103:d:\dados\dat\fb\wlaud\wlaud.gdb'
DeleteSQL.Strings = (
'DELETE FROM L_DIREITO'
'WHERE'
' CODIGO_DIREITO = :OLD_CODIGO_DIREITO')
EditSQL.Strings = (
'UPDATE L_DIREITO SET'
' CODIGO_DIREITO = :CODIGO_DIREITO, /*PK*/'
' ORDEM = :ORDEM,'
' NIVEL = :NIVEL,'
' DESCRICAO = :DESCRICAO,'
' NOME_MODULO = :NOME_MODULO'
'WHERE'
' CODIGO_DIREITO = :OLD_CODIGO_DIREITO')
IB_Connection = IBODatabase
IB_Transaction = IBOTransaction
InsertSQL.Strings = (
'INSERT INTO L_DIREITO('
' CODIGO_DIREITO, /*PK*/'
' ORDEM,'
' NIVEL,'
' DESCRICAO,'
' NOME_MODULO)'
'VALUES ('
' :CODIGO_DIREITO,'
' :ORDEM,'
' :NIVEL,'
' :DESCRICAO,'
' :NOME_MODULO)')
RecordCountAccurate = True
SQL.Strings = (
'select * from L_DIREITO')
FieldOptions = []
Left = 376
Top = 64
end
object IBOTransaction: TIBOTransaction
IB_Connection = IBODatabase
AutoCommit = True
Isolation = tiConcurrency
Left = 408
Top = 32
end
object DataSource: TDataSource
DataSet = qIBOQuery
Left = 408
Top = 64
end
object qExecSQL: TIBOQuery
Params = <>
DatabaseName = '192.168.1.103:d:\dados\dat\fb\wlaud\wlaud.gdb'
IB_Connection = IBODatabase
IB_Transaction = IBOTransaction
RecordCountAccurate = True
FieldOptions = []
Left = 376
Top = 96
end
end

---------------------------------------------------------------------

Hope it Help.

Thank you again.

Antonio Carlos

--- In IBObjects@y..., "Jason Wharton" <jwharton@i...> wrote:
> > PS: Do you still want a simple application?
>
> For sure!
>
> Jason Wharton
> CPS - Mesa AZ
> http://www.ibobjects.com
>
> -- We may not have it all together --
> -- But together we have it all --