Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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