Subject | Re: [IBO] IB_Query x IBOQuery - Using fieldbyname |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-05-18T07:51:06Z |
--- In IBObjects@yahoogroups.com, Helen Borrie wrote:
tmpTabela.ExecSQL;
with
tmpTabela.Open;
I think ExecSQL is more for executing statements (CREATE, UPDATE,
ALTER, INSERT, DELETE etc) than for SELECTing one or more records (and
for executable statements, you should use a TIB_DSQL, not a TIB_Query)
. For unidirectional datasets (where you only ever move forward, never
backward), use a TIB_Cursor and replace tmpTabela.Open; with
tmpTabela.First;
HTH,
Set
> At 11:27 AM 17/05/2005 -0300, you wrote:Also, replace
> >IB-6, IBO 4.5ai (registered) - Delphi 7 Pro
> >-----------------------------------------------------------
> >Dear Friends
> >
> >I need to create and open a table, with IB_query, using this:
> >..............
> > tmpTabela := TIB_Query.Create(Application);
> > with tmpTabela do
> > begin
> > DataBaseName := Salias;
> > tmptabela.SQL.Text := 'SELECT SEMAPHOR.ch_sem,
> > SEMAPHOR.nodulo
> >from SEMAPHOR where CH_SEM = '+quotedStr(SCh_sem);
> > tmpTabela.ExecSQL;
> > end;
> >
> >When the SQL results in one or more fields, after posicioning in
> >the first record, a command like:
> >tmptabela.fieldbyname('ch_sem').AsString yelds empty. Why?
> >
> >When using IBOQuery the result on
> >tmptabela.fieldbyname('ch_sem').AsString yelds the correct content.
> >What I need to do to get the correct content of the field, using
> >IB_Query?
>
> Don't use DatabaseName for IB_Query, use the IB_Connection property.
> You would be well-advised to avoid DatabaseName for IBOQuery as
> well, in preference for IB_Connection.
tmpTabela.ExecSQL;
with
tmpTabela.Open;
I think ExecSQL is more for executing statements (CREATE, UPDATE,
ALTER, INSERT, DELETE etc) than for SELECTing one or more records (and
for executable statements, you should use a TIB_DSQL, not a TIB_Query)
. For unidirectional datasets (where you only ever move forward, never
backward), use a TIB_Cursor and replace tmpTabela.Open; with
tmpTabela.First;
HTH,
Set