www.digitalmars.com         C & C++   DMDScript  

c++ - Problems with DBChart...

reply "Sergio Augusto Bitencourt Petrovcic" <sergioabp automacao.eng.br> writes:
Hello everybody...here´s a problem for you! I´m from Brazil, so sorry about
my english!
I have in a form a TQuery, a TDataSource, a TTable, a TDBGrid, and a
TDBChart.
The table 102003.db has 5 fields: Data, Hora, Corrente, Tensão and Potência.
I created one serie named Series1 in TDBChart. When i click a button for the
first time i execute the program, this code below executes. If the
RadioButton1 is checked ( which means to select only data, hora and
tensão ), it works and show in the TDBChart the right values. The same
occurs when click for the first time i execute a program with the
RadioButton2 checked. The problem occurs when i click for the second time.
If i clicked for the first time with RadioButton1 checked, it works, when i
click other times keeping RadioButton1 checked, it keeps working. But if I
check the other RadioButton, it gives an error saying that the field
Corrente was not found. The same occurs if I click first with RadioButton2
checked and then change to RadioButton1. It says that field Tensão was not
found.
Am i clear??? I don´t know what to do. It seems like I have to diseable the
Series1 or clear it. But I already made it or made it wrong.

PS: The line: Series1->YValues->ValueSource =
DBGrid1->Columns->Items[2]->FieldName;
takes the tird column in the DBGrid as datasource, as result of the select
statement ( Corrente or Tensão ).

Hope anyone can help me!
Thaks...

if(RadioButton1->Checked) {
        Query1->SQL->Clear();
        Query1->Close();
        Query1->SQL->Add("SELECT Data, Hora, Tensão FROM '102003.db'");
        Query1->Open();
}

if(RadioButton2->Checked) {
        Query1->SQL->Clear();
        Query1->Close();
        Query1->SQL->Add("SELECT Data, Hora, Corrente FROM '102003.db'");
        Query1->Open();
}

Series1->DataSource = Query1;
Series1->YValues->ValueSource = DBGrid1->Columns->Items[2]->FieldName;
Series1->XValues->ValueSource = "Data";
Series1->XValues->DateTime = true;
Oct 28 2003
parent gf <mz_y2k yahoo...com> writes:
"Sergio Augusto Bitencourt Petrovcic" <sergioabp automacao.eng.br> wrote
in news:bnmjje$q6m$1 digitaldaemon.com: 

 Hello everybody...here´s a problem for you! I´m from Brazil, so sorry
 about my english!
 I have in a form a TQuery, a TDataSource, a TTable, a TDBGrid, and a
 TDBChart.
 The table 102003.db has 5 fields: Data, Hora, Corrente, Tensão and
 Potência. I created one serie named Series1 in TDBChart. When i click
 a button for the first time i execute the program, this code below
 executes. If the RadioButton1 is checked ( which means to select only
 data, hora and tensão ), it works and show in the TDBChart the right
 values. The same occurs when click for the first time i execute a
 program with the RadioButton2 checked. The problem occurs when i click
 for the second time. If i clicked for the first time with RadioButton1
 checked, it works, when i click other times keeping RadioButton1
 checked, it keeps working. But if I check the other RadioButton, it
 gives an error saying that the field Corrente was not found. The same
 occurs if I click first with RadioButton2 checked and then change to
 RadioButton1. It says that field Tensão was not found.
 Am i clear??? I don´t know what to do. It seems like I have to
 diseable the Series1 or clear it. But I already made it or made it
 wrong. 
 
 PS: The line: Series1->YValues->ValueSource =
 DBGrid1->Columns->Items[2]->FieldName;
 takes the tird column in the DBGrid as datasource, as result of the
 select statement ( Corrente or Tensão ).
 
 Hope anyone can help me!
 Thaks...
 
 if(RadioButton1->Checked) {
         Query1->SQL->Clear();
         Query1->Close();
         Query1->SQL->Add("SELECT Data, Hora, Tensão FROM
         '102003.db'"); Query1->Open();
 }
 
 if(RadioButton2->Checked) {
         Query1->SQL->Clear();
         Query1->Close();
         Query1->SQL->Add("SELECT Data, Hora, Corrente FROM
         '102003.db'"); Query1->Open();
 }
 
 Series1->DataSource = Query1;
 Series1->YValues->ValueSource = DBGrid1->Columns->Items[2]->FieldName;
 Series1->XValues->ValueSource = "Data";
 Series1->XValues->DateTime = true;
Those look A LOT like Borland's components. If they are I can try to help you with it, if you need.
Oct 29 2003