Link to home
Start Free TrialLog in
Avatar of alchemy9
alchemy9

asked on

ADO example. Can someone show me how to traverse a record set.


I am using Delphi 7. Can someone give an example of traversing a recordset,  for example using the  northwind database in sql server, showing  the customer ID colurm information.

I am looking to read this information into an array

Does anyone know of any good tutorial for ado and delphi???

thanks in advance


Ian
SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shaneholmes
shaneholmes

replace MyADOTable with the name of yout TADOTable component
replace MyField with the field name (example: CustomerId)
replace MYArray with your array name

Shane
Avatar of alchemy9

ASKER

wow that was amazingly quick thanks

how would I get the result back from this query

SELECT CASE WHEN is_srvrolemember('sysadmin')=1 OR is_member('db_owner')=1 THEN 1 ELSE 0 END AS output


if you can answer this I will put the points upto 500

cheers

Ian
WHat do you mean how do you get the result back?

If its a valid query, you can use it in a TADOQuery.

is it valid?

You can test it in your sql server monitor

SHane
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Is there any difference in Your code, except of course the letter e which You lost? :)
yeah, how about the prepare statement - or is that invisible on your end....

Shane
oh and the SQL clear  <SMILE>

like i said... MOKULE, if he is interested in using it for multiple sql's ...


Shane
1. When You assigning to Text, Clear is unnecessary in any case.
2. No need to check Prepared as it is always False after assigning to SQL.Text
3. Prepare is performed also when openning.
4. I'm not very sure but preparing such a simple sql without paramaters has rather no sense.
5. Calling prepare explicitly You should also remember to unprepare as the resources are not freed automatically
Thankyou both for you comments they have been exeedingly useful, and very quick, most impressive.

FYI, the sql code does work, it checks the user has suffient rights to add an extended stored procedure.


Ian