DBGrid

240 pts.
Tags:
DBGrid
Delphi
Delphi 5.0
How to iterate through the rows and cols of a dbgrid? Can anyone explain me how to achieve this?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Hello Rajalakshmi08,
normally when working with Grids you use a SQL query; personally prefer creating a grid, connect it to a TDataSource and the TDataSource connected to a TQuery, then i do set the TQuery SQL property:

mQry.SQL.Text := 'SELECT * FROM MY TABLE';
mQry.Open;
dbgrid1.Refresh;
// work/see your data and then
mQry.Close;

If instead you mean reading your data row by row you can do:

mQry.SQL.Text := 'SELECT * FROM MY TABLE';
mQry.Open;
While Not mQry.EOF do
Begin
ShowMessage(mQry.FieldByName('MYFIELD').AsString;
mQry.Next;
End;
mQry.Close;

Bye.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following