www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - Problems with TDBChart..

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
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
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 =
takes the tird column in the DBGrid as datasource, as result of the select
statement ( Corrente or Tensão ).

Hope anyone can help me!

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

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

Series1->DataSource = Query1;
Series1->YValues->ValueSource = DBGrid1->Columns->Items[2]->FieldName;
Series1->XValues->ValueSource = "Data";
Series1->XValues->DateTime = true;
Oct 28 2003