Subject | Re: [IBO] Weird column showing in grid |
---|---|
Author | Markus Ostenried |
Post date | 2011-08-13T01:35:44Z |
On Sat, Aug 13, 2011 at 03:05, squidsrus85 <squidsrus85@...> wrote:
IBObjects does a lot of stuff in the background for you. For that it
needs a column with unique values. Since you didn't select a primary
key column IBO uses db_key instead, which is generated by Firebird and
unique per result set (I think). You have several options:
1) Just hide db_key:
Double click the query (to open it's design time editor), prepare the
query (click the light bulb icon), and then on the FieldProperties tab
select the db_key column and set it's Visible property to False. Have
a look at your IB_Query1.FieldsVisible property afterwards: you can
add these entries to IB_Connection.FieldsVisible, too, so they act as
default for all the queries using that IB_Connection.
2) Use NAME as key:
If your "name" column only contains unique values then you can tell
IBO to use this column instead of db_key: Open the property editor
(like above), select the tab SQL, there select tab KeyLinks and in the
KeyLinks memo field enter NAME and uncheck KeyLinksAutoDefine.
If your statement contains relation aliases (like "select a.name from
tbl_accounts a") then you need to set KeyLinks=A.NAME and
KeyRelation=A.
3) select primary key:
This is what I prefer: in your select statement include the primary
key column (like "select account_id, name from tbl_accounts"), and
then make your account_id column invisible like under 1).
HTH,
Markus
PS: with 2) Maybe if you leave KeyLinksAutoDefine=true then IBO will
fill in KeyLinks and KeyRelation correctly for you. You have to test
it yourself. I'm just used to specifying them myself since I always
use relation aliases and there was a problem with IBO detecting the
KeyRelation correctly.
> Hi All,Hi Dave,
>
> I have a TB-Grind and an SQL statement of
>
> SELECT name FROM TBL_ACCOUNTS whici does what I need, but I am also getting a column with a big number and the header of "DB_KEY"
>
> How can I hide that?
IBObjects does a lot of stuff in the background for you. For that it
needs a column with unique values. Since you didn't select a primary
key column IBO uses db_key instead, which is generated by Firebird and
unique per result set (I think). You have several options:
1) Just hide db_key:
Double click the query (to open it's design time editor), prepare the
query (click the light bulb icon), and then on the FieldProperties tab
select the db_key column and set it's Visible property to False. Have
a look at your IB_Query1.FieldsVisible property afterwards: you can
add these entries to IB_Connection.FieldsVisible, too, so they act as
default for all the queries using that IB_Connection.
2) Use NAME as key:
If your "name" column only contains unique values then you can tell
IBO to use this column instead of db_key: Open the property editor
(like above), select the tab SQL, there select tab KeyLinks and in the
KeyLinks memo field enter NAME and uncheck KeyLinksAutoDefine.
If your statement contains relation aliases (like "select a.name from
tbl_accounts a") then you need to set KeyLinks=A.NAME and
KeyRelation=A.
3) select primary key:
This is what I prefer: in your select statement include the primary
key column (like "select account_id, name from tbl_accounts"), and
then make your account_id column invisible like under 1).
HTH,
Markus
PS: with 2) Maybe if you leave KeyLinksAutoDefine=true then IBO will
fill in KeyLinks and KeyRelation correctly for you. You have to test
it yourself. I'm just used to specifying them myself since I always
use relation aliases and there was a problem with IBO detecting the
KeyRelation correctly.