Subject | RES: [IBO] FieldEntryTypes := [fetSQLType]; |
---|---|
Author | |
Post date | 2014-08-14T16:30:17Z |
I use so the performace is excellent
unit U_TESTE;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,IB_Components,IBODataset,db, Vcl.Buttons,
Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids;
type
TF_TESTE = class(TForm)
DBGridBusca: TDBGrid;
DBNavigatorBusca: TDBNavigator;
LabeledEditBuscar: TLabeledEdit;
SpeedButtonBuscar: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SpeedButtonBuscarClick(Sender: TObject);
private
{ Private declarations }
procedure Seta_Grid(F_DATASOURCE:TDataSource;F_CAMPOS,F_TITULOS,F_TAMANHO:array of String);
public
{ Public declarations }
end;
type
TPessoasController = class
protected
public
function Abre_Pessoas(Conexao:TIBODatabase;Transacao:TIBOTransaction;SQLString:String;Status:Boolean):TIBOQuery;
end;
var
F_TESTE: TF_TESTE;
Conexao : TIBODatabase;
Transacao : TIBOTransaction;
QueryPessoas : TIBOQuery;
DataSourcePessoas : TDataSource;
PessoasControl : TPessoasController;
implementation
{$R *.dfm}
function TPessoasController.Abre_Pessoas(Conexao:TIBODatabase;Transacao:TIBOTransaction;SQLString:String;Status:Boolean):TIBOQuery;
var
QueryLocal : TIBOQuery;
begin
try
QueryLocal := TIBOQuery.Create(nil);
QueryLocal.IB_Connection := Conexao;
QueryLocal.IB_Transaction := Transacao;
try
with QueryLocal do
begin
Close ;
ReadOnly := not Status;
RequestLive := Status;
UnPrepare;
Sql.Clear;
Sql.Add(SQLString);
Prepare;
Open;
end;
result := QueryLocal;
except
result := QueryLocal;
end;
finally
//
end;
end;
procedure TF_TESTE.FormCreate(Sender: TObject);
begin
Conexao := TIBODatabase.Create(nil);
Transacao := TIBOTransaction.Create(nil);
Transacao.AutoCommit := True;
Transacao.ServerAutoCommit := True;
Transacao.Isolation := tiCommitted;
Conexao.DatabaseName := 'c:\sis_spa\dados\spajaresdb.fdb';
Conexao.Username := 'SYSDBA';
Conexao.PassWord := 'masterkey';
Conexao.Activate;
DataSourcePessoas := TDataSource.Create(nil);
end;
procedure TF_TESTE.Seta_Grid(F_DATASOURCE:TDataSource;F_CAMPOS,F_TITULOS,F_TAMANHO:array of String);
var R:Integer;
begin
DBGridBusca.Columns.Clear;
DBGridBusca.DataSource := F_DATASOURCE;
for R := 0 to High(F_CAMPOS) do
begin
DBGridBusca.Columns.Add;
DBGridBusca.Columns[R].FieldName := F_CAMPOS[R];
DBGridBusca.Columns[R].Title.Caption := F_TITULOS[R];
DBGridBusca.Columns[R].Width := StrToInt(F_TAMANHO[R]);
Application.ProcessMessages;
end;
DBNavigatorBusca.DataSource := F_DATASOURCE;
end;
procedure TF_TESTE.FormShow(Sender: TObject);
begin
PessoasControl := TPessoasController.Create;
DataSourcePessoas := TDataSource.Create(Application);
Seta_Grid(DataSourcePessoas,['ID','NOME','ENDERECO','TELEFONE'],
['Id','Nome','Endereço','Telefone'],
['40','200','200','125']);
end;
procedure TF_TESTE.SpeedButtonBuscarClick(Sender: TObject);
begin
QueryPessoas := PessoasControl.Abre_Pessoas(Conexao,Transacao,'SELECT * FROM PESSOAS WHERE NOME LIKE ' + QuotedStr(LabeledEditBuscar.Text + '%' ) + ' ORDER BY NOME',False);
DataSourcePessoas.DataSet := QueryPessoas;
end;
end.
De: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Enviada em: quinta-feira, 14 de agosto de 2014 10:29
Para: IBObjects@yahoogroups.com
Assunto: [IBO] FieldEntryTypes := [fetSQLType];
Hi...I'm testing IBO on my application and I'm having a little problem with TIBOQuery. I change a lot of the code to use TIB_Query and works fine, but in some places like Reports that need the TDataset I'm using the TIBOQuery. The problem is that it takes too long time to get the result set. I try to change in TIBODatabase the FieldEntryTypes := [fetSQLType] and then de TIBOQuery now is working very faster but I'm having some other issues like long time to connect to de Databases. Without the FieldEntryTypes := [fetSQLType], just FieldEntryTypes := [] the connection is normal, works fine over internet connections with no problems, but then the TIBOQuery becomes a problem.I think the problem is on Prepare, thats occurs when I set a paramByName for example. The problem dont affect the TIB_Query component.I don't know if I need to send you more details but if someone knows how to avoid this!!Tanks...Jean
[Non-text portions of this message have been removed]
unit U_TESTE;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,IB_Components,IBODataset,db, Vcl.Buttons,
Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.Grids, Vcl.DBGrids;
type
TF_TESTE = class(TForm)
DBGridBusca: TDBGrid;
DBNavigatorBusca: TDBNavigator;
LabeledEditBuscar: TLabeledEdit;
SpeedButtonBuscar: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SpeedButtonBuscarClick(Sender: TObject);
private
{ Private declarations }
procedure Seta_Grid(F_DATASOURCE:TDataSource;F_CAMPOS,F_TITULOS,F_TAMANHO:array of String);
public
{ Public declarations }
end;
type
TPessoasController = class
protected
public
function Abre_Pessoas(Conexao:TIBODatabase;Transacao:TIBOTransaction;SQLString:String;Status:Boolean):TIBOQuery;
end;
var
F_TESTE: TF_TESTE;
Conexao : TIBODatabase;
Transacao : TIBOTransaction;
QueryPessoas : TIBOQuery;
DataSourcePessoas : TDataSource;
PessoasControl : TPessoasController;
implementation
{$R *.dfm}
function TPessoasController.Abre_Pessoas(Conexao:TIBODatabase;Transacao:TIBOTransaction;SQLString:String;Status:Boolean):TIBOQuery;
var
QueryLocal : TIBOQuery;
begin
try
QueryLocal := TIBOQuery.Create(nil);
QueryLocal.IB_Connection := Conexao;
QueryLocal.IB_Transaction := Transacao;
try
with QueryLocal do
begin
Close ;
ReadOnly := not Status;
RequestLive := Status;
UnPrepare;
Sql.Clear;
Sql.Add(SQLString);
Prepare;
Open;
end;
result := QueryLocal;
except
result := QueryLocal;
end;
finally
//
end;
end;
procedure TF_TESTE.FormCreate(Sender: TObject);
begin
Conexao := TIBODatabase.Create(nil);
Transacao := TIBOTransaction.Create(nil);
Transacao.AutoCommit := True;
Transacao.ServerAutoCommit := True;
Transacao.Isolation := tiCommitted;
Conexao.DatabaseName := 'c:\sis_spa\dados\spajaresdb.fdb';
Conexao.Username := 'SYSDBA';
Conexao.PassWord := 'masterkey';
Conexao.Activate;
DataSourcePessoas := TDataSource.Create(nil);
end;
procedure TF_TESTE.Seta_Grid(F_DATASOURCE:TDataSource;F_CAMPOS,F_TITULOS,F_TAMANHO:array of String);
var R:Integer;
begin
DBGridBusca.Columns.Clear;
DBGridBusca.DataSource := F_DATASOURCE;
for R := 0 to High(F_CAMPOS) do
begin
DBGridBusca.Columns.Add;
DBGridBusca.Columns[R].FieldName := F_CAMPOS[R];
DBGridBusca.Columns[R].Title.Caption := F_TITULOS[R];
DBGridBusca.Columns[R].Width := StrToInt(F_TAMANHO[R]);
Application.ProcessMessages;
end;
DBNavigatorBusca.DataSource := F_DATASOURCE;
end;
procedure TF_TESTE.FormShow(Sender: TObject);
begin
PessoasControl := TPessoasController.Create;
DataSourcePessoas := TDataSource.Create(Application);
Seta_Grid(DataSourcePessoas,['ID','NOME','ENDERECO','TELEFONE'],
['Id','Nome','Endereço','Telefone'],
['40','200','200','125']);
end;
procedure TF_TESTE.SpeedButtonBuscarClick(Sender: TObject);
begin
QueryPessoas := PessoasControl.Abre_Pessoas(Conexao,Transacao,'SELECT * FROM PESSOAS WHERE NOME LIKE ' + QuotedStr(LabeledEditBuscar.Text + '%' ) + ' ORDER BY NOME',False);
DataSourcePessoas.DataSet := QueryPessoas;
end;
end.
De: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Enviada em: quinta-feira, 14 de agosto de 2014 10:29
Para: IBObjects@yahoogroups.com
Assunto: [IBO] FieldEntryTypes := [fetSQLType];
Hi...I'm testing IBO on my application and I'm having a little problem with TIBOQuery. I change a lot of the code to use TIB_Query and works fine, but in some places like Reports that need the TDataset I'm using the TIBOQuery. The problem is that it takes too long time to get the result set. I try to change in TIBODatabase the FieldEntryTypes := [fetSQLType] and then de TIBOQuery now is working very faster but I'm having some other issues like long time to connect to de Databases. Without the FieldEntryTypes := [fetSQLType], just FieldEntryTypes := [] the connection is normal, works fine over internet connections with no problems, but then the TIBOQuery becomes a problem.I think the problem is on Prepare, thats occurs when I set a paramByName for example. The problem dont affect the TIB_Query component.I don't know if I need to send you more details but if someone knows how to avoid this!!Tanks...Jean
[Non-text portions of this message have been removed]