Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

dbgride question ?

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
peruzzi
Asked:
peruzzi
  • 4
  • 2
  • 2
2 Solutions
 
shaneholmesCommented:
If you are using a DBGrid,

 fields[0]

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


Shane

 
0
 
shaneholmesCommented:
ShowMessage(DBGrid1.DataSource.DataSet.Fields[0].asString);

Shane
0
 
shaneholmesCommented:
OR if you know your table name

  MyTable.Fields[0].asString;

Shane
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
peruzziAuthor Commented:
I will try it

peruzzi
0
 
mokuleCommented:

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
 
peruzziAuthor Commented:
Hi
all what you say is true
so I  wish you will be agree with my spliting points between you

thanks my friends
0
 
mokuleCommented:
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
 
shaneholmesCommented:
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now