Isaac Badru
Members-
Content Count
12 -
Joined
-
Last visited
Community Reputation
0 Neutral-
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
As long as we are healthy we can always learn something more I hope to learn French, Russian, Indian or Chinese -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Its time to english people start to learn other languages hehe -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Hi, I understand that its better to each city have a differently ID, but as nobody will add or delete any city i did like that, but ok, I can do look like this to connect the referential country: INSERT INTO country (id, country_id,country_name) VALUES (NULL, '2', 'Brazil'); INSERT INTO city (id, city_id, CITY_COUNTRY_ID, city_name) VALUES (NULL, '1', '2 ', 'Rio de janeiro'); INSERT INTO city (id, city_id, CITY_COUNTRY_ID, city_name) VALUES (NULL, '2', ' 2', 'Sao Paulo'); INSERT INTO country (id, country_id, country_name) VALUES (NULL, '4', 'USA'); INSERT INTO city (id, city_id, CITY_COUNTRY_ID, city_name) VALUES (NULL, '3', '4 ', 'California'); INSERT INTO city (id, city_id, CITY_COUNTRY_ID, city_name) VALUES (NULL, '4', '4 ', 'New York'); in the country FDQuery : select * from country; in the city FDQuery : select * from city inner join country where city.CITY_COUNTRY_ID=country.country_id; ************* last INSERT INTO country (id, country_id, country_name) VALUES (NULL, '2', 'Brazil'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '2', 'Rio de janeiro'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '2', 'Sao Paulo'); INSERT INTO country (id, country_id, country_name) VALUES (NULL, '4', 'USA'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '4', 'California'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '4', 'New York'); in the country FDQuery I put it: select * from country; in the city FDQuery I put it: select * from city inner join country where city.city_id=country.country_id; Well, I don't know how to do it, what I would like to do is select a lookupcombobox or combobox country and then when selecting in the other lookupcombobox or combobox only the respective cities of that country appear thanks -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Good morning, I had written in English, but when I saw that the vfbb member is from Brazil, I preferred to speak in Portuguese to easily and better understand each other As for Mr. Dany Marmur, I didn't understand if he don't understand Delphi or Portuguese language -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
See 1st post -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Camarada, entenda, não disse que teu codigo não esteja perfeito, apenas não foste ao encontro do meu problema Eu preciso de soluçao com Lookup combobox e não Combobox Eu quero selecionar um pais e no outro butao apenas aparecerem as cidades correspondentes, so isso Obrigado -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
ANYTHING, its AMBIGUOUS -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
vfbb Vamos a isso ... -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Viva a principio eu gostaria de usar lookupCombobox para usar dados da Base de dados e nao combobox, mas enfim, sendo cidades e Paises sempre serao os mesmos dados e porderiam ficar num combobox, mas poder, me ensinas a fazer relaçoes no combobox Por acaso nunca gostei de arrays dai tive dificuldades , nestes trechos por exemplo, nao entendi o que seria LCitiesIds := LCitiesIds + [FieldByName('city_id').AsInteger]; ComboboxCity.Items.Add(FieldByName('city_name').AsString); Tentei fazer umas adaptaçoes aqui ao jeito que entendo... Ja que eu uso uma UDM onde ficam todas as FDQ's tentei fazer abaixo, peço pra melhorares a parte dos arrays, pois nao sou nada bom em arrays Segue o codigo que tentei melhorar, so tens de criar dois combobox : ComboboxCity , ComboboxCountry unit UnitTeste; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.DBCtrls; type TForm1 = class(TForm) ComboboxCountry: TComboBox; ComboboxCity: TComboBox; procedure FormShow(Sender: TObject); procedure ComboboxCountryChange(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses UDM; procedure TForm1.ComboboxCountryChange(Sender: TObject); var LCountriesIds : array of integer; LCitiesIds : array of integer; begin with DM.FDQuery1 do begin ComboboxCity.Items.Clear; SetLength(LCitiesIds, 0); // Imagino ser o tamanho do array , é isso ? if ComboboxCity.ItemIndex = -1 then Exit; // SQL.aDD ('SELECT city.city_id, city.city_name FROM city inner join Country WHERE city.country_id=country_id ORDER BY city.city_name ASC;'); // ... BY city.city_name ASC;' da erro com o ASC // ...WHERE city.country_id=country_id // country_id= :country_id // essses (:) foi erro ? SQL.aDD ('SELECT City.city_id, City.city_name FROM City inner join Country WHERE City.city_id =Country.country_id;'); ParamByName('country_id').AsInteger := LCountriesIds[ComboboxCity.ItemIndex]; Open; try while not DM.FDQuery1.Eof do begin LCitiesIds := LCitiesIds + [FieldByName('city_id').AsInteger]; ComboboxCity.Items.Add(FieldByName('city_name').AsString); Next; end; finally Close; end; end; end; procedure TForm1.FormShow(Sender: TObject); var LCountriesIds : array of array of integer; begin with DM.FDQCountry do begin ComboboxCountry.Items.Clear; SetLength(LCountriesIds, 0); SQL.Text := 'SELECT Country.country_id, Country.country_name FROM Country ORDER BY Country.country_name ASC;'; Open; try while not DM.FDQCountrys.Eof do begin // LCountriesIds := LCountriesIds + [FieldByName('codigoP').AsInteger]; // Incompatible types: Dynamic array an integer ComboboxCountry.Items.Add(FieldByName('country_id').AsString); Next; end; finally Close; end; // ComboBox1Change(nil); // FireDAC.Stan.Param uis not specified in USES list end; end; end. Assim ficou a imagem em combobox -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Sim amigo, mas ainda não consegui como vés -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru replied to Isaac Badru's topic in Delphi IDE and APIs
Correction : I created a birthplace DB, with two tables, country (id, country_Id, country_name) and city (id, city_Id, city_name) in Xampp Bom dia vfbb, obrigado, o que pretendo é que na minha aplicação após selecionar o país na lookcombobox país, ao selecionar a cidade na lookcombobox cidade apenas apareçam as cidades correspondentes do país anteriormente selecionado, como podes ver na imagem abaixo, está a mostrar todas cidades A outra coisa que gostaria que me dissesses é se teria de implementar o código na FDQuery da cidade ou no procedimento dentro do form ? -
lookupcombobox Delphi - lookupCombobox - values from relatioship
Isaac Badru posted a topic in Delphi IDE and APIs
Hello everyone Sorry about my english, Im from Mozambique and its not my mother Language I'm developing in Delphi, I created a birthplace table (id, country_Id, country_name) and city (id, city_Id, city_name) in Xampp, then INSERT INTO country (id, country_id, country_name) VALUES (NULL, '2', 'Brazil'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '2', 'Rio de janeiro'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '2', 'Sao Paulo'); INSERT INTO country (id, country_id, country_name) VALUES (NULL, '4', 'USA'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '4', 'California'); INSERT INTO city (id, city_id, city_name) VALUES (NULL, '4', 'New York'); in the country FDQuery I put it: select * from country; in the city FDQuery I put it: select * from city inner join country where city.city_id=country.country_id; and have city_id city_name country_id country_name 2 Rio de janeiro 2 Brazil 2 Sao Paulo 2 Brazil 4 California 4 USA 4 New York 4 USA Its Ok, But when I select a country in the Lookupcombobox, (eg USA), when I select the city in the city Lookupcombobox it brings all cities, but, coundnt Please Help