Newbie question No.2

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
winsth
Posts: 3
Joined: Sat 06 May 2006 19:09
Contact:

Newbie question No.2

Post by winsth » Mon 08 May 2006 13:14

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!

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 10 May 2006 12:18

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;

Post Reply