Creating tables and displaying without RAD components

210 Views Asked by At

My job gave me a challenge to do the following... I am still a rookie and learning as fast as I can but I have this curve ball and can't quite get my mind to it.

If it is not to much trouble... how can I create, modify and display Tables with the below exceptions?

RAD is out. No dataset, query or table components of any kind. For example, don’t use : DataSource, DataSet, DBGrid, DBText, DBEdit etc.) A connection component like TADOConnection is acceptable.

2

There are 2 best solutions below

2
alzaimar On

You can use the ADOConnection.Execute Method to fetch data from a query and then iterate and display in some sort of manner, e.g. using a TStringGrid or the famous TVirtualTreeView

0
Pieter B On

If you can use adoconnection, you can probably use the ADOQuery component.

Then you get something like this:

sl.Clear;
ADOQuery.Close;
try
  ADOQuery.SQL.Text:='SELECT names FROM phonebook';
  ADOQuery.Open;
  While not ADOQuery.Eof do begin
    sl.Add(AdoQuery.FieldByName('names').AsString);
    ADOQuery.Next;
  end;
finally
  ADOQuery.Close;
end;

or:

ADOQuery.Close;
try
  ADOQuery.SQL.Text := 'INSERT INTO phonebook (name,number)VALUES'+QuotedStr(NameString) +',' + QuotedStr(numberstring) +')'
  ADOQuery.ExecSQL;
finally
  ADOQuery.Close;
end;

(this uses non-parameterized queries, using parameterized queries is ofcourse better.)