Solved

DBGrid(c++)

Posted on 2000-04-08
6
882 Views
Last Modified: 2006-11-17
Hi,(this is BBuilder c++ question)

How can I read data in containd in DBGrid ?
I wont to read for example all values which are in  field 2

I make it works with dbgrid navigator but that's to messy
I also have found  following line of code but it is for Delphi and for some reason it don't work

DBGrid1.Columns[4].Field.AsString
I try to do following
DBGrid1->Columns[2]->Field->AsString;
but it reports error.

This is how i made it with db navigator

for (int z=0;z<RecordCount;z++) {
   zbir = zbir +Form1->DBGrid1->Fields[2]->AsInteger;//I need to accumulate all values containd in all cells inside field[2]
      Form1->DBNavigator1->BtnClick(nbNext);//and move to next cell
  }

How can i acces this data's not using dbnavigator



0
Comment
Question by:xtvca
  • 4
  • 2
6 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2695973
for (int z=0;z<RecordCount;z++)???
whats are .... :o)

You do not need to manipulate with DBGrig, just do it with your DataSet.

Table1 -> first
while Table1 -> EOF do
begin
    SomeValue := Table1->Fields[2]->AsWhatYouWant;
   Table1->Next;
end;

----
Igor
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2695975
typo...
while not Table1-> EOF
0
 

Author Comment

by:xtvca
ID: 2695986
I'm not working with tables but with SQL query's
Thats why i need to read data from DBGrid (or is there is some better solution I wold be happy to hear (i'm still begginer))

Regards
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Accepted Solution

by:
ITugay earned 19 total points
ID: 2696028
Just change Table1 to Query1 ;)

Now seriously. The code bellow is sample how to extract all fields value from given table.
--------
Query1 is TQuery;
ListBox1 is TListBox it will filled out by Query1.Fields[1] values;
-------

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
   Listbox1.Clear;  // clear content of ListBox
   Query1.Open;  // open query
   while not Query1.EOF do // do for all records in Query1
   begin
      ListBox1.Items.Add(Query1.Fields[1].AsString); // add first field value to ListBox
      Query1.Next; // goto next record
   end;
   Query1.Close; // close Query
end;

-----

To repeat this sample in your applcation drop TQuery, TListBox, TSpeedButton components on your form and copy/paste xode above to you OnButtonClick procedure.

------
Igor.

PS: it's Delphi, OK?
0
 

Author Comment

by:xtvca
ID: 2696141
GREAT IT WORKS

Line is :
ListBox1->Items->Add(Query1->Fields->Fields[2]->AsString); // add first field value to ListBox

THANKS
&REGARDS

0
 
LVL 9

Expert Comment

by:ITugay
ID: 2696148
;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

930 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

14 Experts available now in Live!

Get 1:1 Help Now