Solved

dbgride question ?

Posted on 2004-04-12
8
170 Views
Last Modified: 2010-10-05
Hi

How can I get the value of  field from the first column when I select the row

I am waiting your answers

peruzzi
0
Comment
Question by:peruzzi
  • 4
  • 2
  • 2
8 Comments
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10808761
If you are using a DBGrid,

 fields[0]

 if its a string or you want it as a string, fields[0].asString


Shane

 
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 30 total points
ID: 10808780
ShowMessage(DBGrid1.DataSource.DataSet.Fields[0].asString);

Shane
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10808790
OR if you know your table name

  MyTable.Fields[0].asString;

Shane
0
 

Author Comment

by:peruzzi
ID: 10808798
I will try it

peruzzi
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 17

Assisted Solution

by:mokule
mokule earned 20 total points
ID: 10808909

I would always advice getting data using its name.
In most cases it is just what are interested in.

DBGrid1.DataSource.DataSet.FieldByName('Cst_firstname').asString;
0
 

Author Comment

by:peruzzi
ID: 10809181
Hi
all what you say is true
so I  wish you will be agree with my spliting points between you

thanks my friends
0
 
LVL 17

Expert Comment

by:mokule
ID: 10809306
Hi peruzzi
Never mind points. But believe me absolutely avoid getting data by column number. I'm sure Shane will tell You the same.
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 10809433
I will tell you that it is recommended that you use the FieldByName method versus the fields array. Whether or not you should "absolutely  avoid" it,  could be called into question. I have used it successfuly in the past, but I try to stay away from using it, and most always use the FieldByName.

I didn't know exactly what you were trying to achieve, and your question was little hard to understand, but when I saw "first column", i thought thats what you were looking for.

Thanks Mokule!

Shane

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now