Solved

DBGrid(c++)

Posted on 2000-04-08
6
881 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
Comment Utility
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
Comment Utility
typo...
while not Table1-> EOF
0
 

Author Comment

by:xtvca
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 9

Accepted Solution

by:
ITugay earned 19 total points
Comment Utility
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
Comment Utility
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
Comment Utility
;)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Get height of a forms top border. 3 32
Convert Jpg /PNG To GIF 5 102
Delphi Form ownership 4 50
control image tags in a string ? 12 59
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

12 Experts available now in Live!

Get 1:1 Help Now