1
In the following code, it should present me the columns of a table I have on my system, but when clicking to display the options in the combobox nothing appears. However if I start typing the name of the field for example Nome_it completes with Name_rsocial and displays the result correctly.
the code:
cbbColunas.Items.Clear();
with TADOQuery.Create(Self) do
begin
Connection := ADOConnection1;
SQL.Text := 'SELECT '+ ' c.name '+
'FROM '+ ' Sys.Columns c '+
'LEFT OUTER JOIN '+
' sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id '
+ 'LEFT OUTER JOIN '+
' sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id '
+ 'WHERE '+
' c.object_id = OBJECT_ID(:tabela)';
Parameters.ParamByName('tabela').DataType := ftString; Parameters.ParamByName('tabela').Value := cbbTabelas.Text;
Open();
First();
while not Eof do begin cbbColunas.Items.Add(FieldByName('name').AsString);
Next();
end;
end;
And this code presented is being called where ?
– Junior Moreira
onchange of the combobox
– Guilherme Lima
where I am can not run Delphi, there on Where where you are searching for the parameter, try to use a LIKE. Question, need to use the parameter ?
– Junior Moreira
I can try with the Like, at lunch I test and return here
– Guilherme Lima
It didn’t work, what intrigues me is that if I type some text in the combo, the columns appear, but if I click them they do not fill the combo.
– Guilherme Lima
I decided to put the code in onmouseenter, is not the right but solves my case at the moment.
– Guilherme Lima
Strange, the chance should already work! But I’m glad you found a solution!
– Junior Moreira
I fully agree, I tested the version of Delphi tested in 2 different. and continued.. I will leave there maybe someone give me a light.
– Guilherme Lima
The onchange event is triggered when you start typing something, it would not be simpler for you to use a Dbcombobox with all the data already filled?
– Harry