I'm using borland c++ builder 6 and ADO.

i have a problem to make database connector with ADO.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
TADODataSet *tmp = new TADODataSet(this);
tmp->Connection = altiCon;
tmp->CommandText = "SELECT COUNT(*) FROM Manager_Config";
tmp->Open();
 
tmp->Fields->Clear();
tmp->Close();
tmp->CommandText = "SELECT * FROM Manager_Config";
tmp->Open();
while (!tmp->Eof) {
    int a = tmp->FieldByName("version")->AsInteger;
    tmp->Next();
}
 
tmp->Close();
delete tmp;


this is my code.
the problem is it does not update fields information.

for example. first query (SELECT COUNT(*) FROM Manager_Config) makes fields.
so, i can get the values with tmp->FieldByName("---")

in second query (SELECT * FROM Manager_Config) does not make fields.
so, i can't get the values with tmp->fieldByNames("---").
i can get the values only with tmp->fields->fields[0].

how can i refresh fields information after each opening TADODataSet?

thanks.
Have you tried making a separate TADODataSet object for each query?

I would not enjoy having to work with the documentation I found on this topic:
http://docwiki.embarcadero.com/Libraries/XE2/en/Data.Win.ADODB.TADODataSet
http://docwiki.embarcadero.com/VCL/XE/en/DB.TDataSet.Fields
http://docwiki.embarcadero.com/VCL/XE/en/DB.TDataSet.FieldByName

Documentation does mention that FieldByName is the preferred method over the Fields list. I hope that using separate objects for each query fixes your problem.
Topic archived. No new replies allowed.