Page 1 of 1

Newbie question No.2

Posted: Mon 08 May 2006 13:14
by winsth
Hi again and thanks for the quick reply (last time)...

I have another small question that I believe most of you will be able to answer directly.

Assume this scenario;
query: "SELECT * FROM table"

I now need to analyze the results in different ways. I've been using PHP until now so I'm used to doing something like this:
while ($row=mysql_fetch_assoc($result)) { etc.
which gives me the opportunity to for example put some of the data in an array or whatever I like to do with it.

Fuzzy? I'm sorry... I'm not that good at explaining things...

So.. the first thing I need to do is to put all the results from "column1" in the table into an array... (std::string _usrname[]). How can I do this?

Feel free to contact me at ICQ if you have any further questions about what I mean.

Many thanks in advance! Have a great day!

Posted: Wed 10 May 2006 12:18
by Antaeus
This question concerns common issues of using TDataSet. You can read more about this in the Delphi help.
In your case you should use something like this:

Code: Select all

MyQuery.First;
while not (MyQuery.EOF) do begin
  arr[i] := MyQuery.FieldByName('IntFld').AsInteger;
  inc(i);
  MyQuery.Next;
end;