Delphi database acces data from a datasource -


i've build dataset in delphi in have adoquery selectes 2 colums table... drag , dropped column adoquery form, how can acces values column. want put values combobox.

unit scarabica;  interface  uses   windows, messages, sysutils, variants, classes, graphics, controls, forms,   dialogs, stdctrls, db, mask, dbctrls, grids, dbgrids;  type   tform1 = class(tform) combobox1: tcombobox;     dbgrid1: tdbgrid;     label9: tlabel;     dbedit1: tdbedit;     datasource1: tdatasource;     procedure formcreate(sender: tobject);   private     { private declarations }   public     { public declarations }   published   end;  var   form1: tform1; implementation  {$r *.dfm}  procedure tform1.formcreate(sender: tobject); begin  end;  end. 

dataset code

unit scarabicadataset;  interface  uses   sysutils, classes, fmtbcd, db, sqlexpr, adodb;  type   tdatamodule1 = class(tdatamodule)     ad: tadoconnection;     adoquery1: tadoquery;     adoquery1categoriepermisid: tintegerfield;     adoquery1categorie: twidestringfield;   private     { private declarations }   public     { public declarations }   end;  var   datamodule1: tdatamodule1;  implementation  {$r *.dfm}  end. 

i'm new delphi can guide me tutorials on how build program in delphi acces databases?

in opinion, design add method in tdatamodule1 fetch records dataset , fill tstrings. main code, pass combobox.items.

procedure tdatamodule1.fetchrecords(outstrings : tstrings); begin     adoquery1.sql.text := 'select company companies country="belgium"';     adoquery1.open;     while not adoquery1.eof begin         outstrings.add(adoquery1.fields[0].asstring;         adoquery1.next;     end; end; 

then can write code in form:

combobox1.items.clear; datamodule1.fetchrecords(combobox1.items); 

i typed out of head, maybe minor error, idea...


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -