^^^^ Don't use the above example.. i've revised it a bit...
Replace your ADOTable component with an ADOQuery component. It works almost exactly the same except it has a SQL property instead of TableName. You can query your database in a way that will use the "UK" field to look up it's value in a different table you should create where it's called "United Kingdom" if you create another table.
Create a new table containing three fields:
CountryID (integer/autonumbered),
CountryAbbr (string),
CountryDescription (string). Heck, call it Countries
Fill it with records (one for each country) e.g. one record where CountryAbbreviation = "UK" and CountryDescription = "United Kingdom", another where CountryAbbr = "USA" and CountryDescription = "United States of America", hey... make another one just in case without the A, CountryAbbr = "US" and CountryDescription = "United States of America"
Then, fill the ADOQuery.SQL text with the appropriate SQL statement before using the ADOQuery.Open method.
with ADOQuery1.SQL do
begin
Clear;
Add('SELECT * FROM YOUR_TABLE_NAME');
Add('LEFT OUTER JOIN COUNTRY_TABLE_NAME');
Add('ON YOUR_TABLE_NAME.YOUR_COUNT
Add('WHERE YOUR_TABLE_NAME.CountryAbb
end;
ADOQuery1.Open;
Of course you are going to have to play with the SQL to get the table and field names right.
Main Topics
Browse All Topics





by: deluzionPosted on 2003-04-12 at 21:07:53ID: 8320877
Replace your ADOTable component with an ADOQuery component. It works almost exactly the same except it has a SQL property instead of TableName. You can query your database in a way that will use the "UK" field to look up it's value in a different table you should create where it's called "United Kingdom" if you create another table.
r = COUNTRY_TABLE_NAME.Country Abbr')
Create a new table containing three fields:
CountryID (integer/autonumbered),
CountryAbbr (string),
CountryDescription (string). Heck, call it Countries
Fill it with records (one for each country) e.g. one record where CountryAbbreviation = "UK", another where CountryDescription = "United Kingdom" for each country.
Then, fill the ADOQuery.SQL text with the appropriate SQL statement before using the ADOQuery.Open method.
with ADOQuery1.SQL do
begin
Clear;
Add('SELECT * FROM YOUR_TABLE_NAME, COUNTRY_TABLE_NAME');
Add('WHERE YOUR_TABLE_NAME.CountryAbb
Add('ORDER BY YOUR_ORDER_FIELD');
end;
ADOQuery1.Open;
of course you are going to have to play with the SQL to get the table and field names right.