Stretchwickster
Programmer
Hi,
I'm new to using ADO components. I have successfully managed to populate a TComboBox with some fields from a database using the following code.
What I am trying to do now is to add the associated "VenueID" to the combobox item as a TObject by using the AddItem method, as you can see from the following code.
However, this code does not run. An EDatabaseError appears saying 'ADOTable_Venue: Field 'VenueID' not found'. I have checked and double-checked and my venue table definitely contains a field called "VenueID" of type AutoNumber. In fact it is the primary key for that table.
I've probably made a blindingly obvious error but I can't spot it. So, does anyone know how to resolve this?
Your help would be much appreciated!
Clive![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
I'm new to using ADO components. I have successfully managed to populate a TComboBox with some fields from a database using the following code.
Code:
Cb_VenueList.Items.Clear;
ADOTable_Venue.First;
while not ADOTable_Venue.EOF do
begin
Cb_VenueList.Items.Add(ADOTable_Venue.FieldByName('Name').AsString + ', ' +
ADOTable_Venue.FieldByName('Town').AsString);
ADOTable_Venue.Next;
end;
What I am trying to do now is to add the associated "VenueID" to the combobox item as a TObject by using the AddItem method, as you can see from the following code.
Code:
Cb_VenueList.Items.Clear;
ADOTable_Venue.First;
while not ADOTable_Venue.EOF do
begin
Cb_VenueList.AddItem(ADOTable_Venue.FieldByName('Name').AsString + ', ' +
ADOTable_Venue.FieldByName('Town').AsString,
TObject(ADOTable_Venue.FieldByName('VenueID').AsInteger));
ADOTable_Venue.Next;
end;
However, this code does not run. An EDatabaseError appears saying 'ADOTable_Venue: Field 'VenueID' not found'. I have checked and double-checked and my venue table definitely contains a field called "VenueID" of type AutoNumber. In fact it is the primary key for that table.
I've probably made a blindingly obvious error but I can't spot it. So, does anyone know how to resolve this?
Your help would be much appreciated!
Clive
![[infinity] [infinity] [infinity]](/data/assets/smilies/infinity.gif)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096