R
Randy Yates
Having done a bit of Access Basic programming, I'm realizing
that AB does seem to have (as much as I hate to admit it since
I think it's a toy language) an advantage over C++.
Let's say I have a table called "tblCars" that has the fields fYear
(integer), fModel (string), fMake (string). When I perform a query in
AB, I do something like:
Dim rstCars As Recordset
Dim year As Integer
set rstCars = dbCurrent.OpenRecordset("SELECT * FROM tblCars")
Now here's the rub: I can then access the fields of the recordset
as
year = rstCars!fYear
AB has syntax that allows me to make such a construction at compile-time
that will yield a dynamic result at run-time.
So my basic question is, is there any mechanism in C++ to do a similar
thing?
The closest I can come is to define a recordset object that has a member
function
void * Fields(char* fName);
so that I can say
int year;
recordset rstCars("SELECT * FROM tblCars");
year = rstCars.Fields("fYear");
Is this a reasonable way to do this? Is there any mechanism in C++ to
do it more elegantly?
--
% Randy Yates % "Watching all the days go by...
%% Fuquay-Varina, NC % Who are you and who am I?"
%%% 919-577-9882 % 'Mission (A World Record)',
%%%% <[email protected]> % *A New World Record*, ELO
http://home.earthlink.net/~yatescr
that AB does seem to have (as much as I hate to admit it since
I think it's a toy language) an advantage over C++.
Let's say I have a table called "tblCars" that has the fields fYear
(integer), fModel (string), fMake (string). When I perform a query in
AB, I do something like:
Dim rstCars As Recordset
Dim year As Integer
set rstCars = dbCurrent.OpenRecordset("SELECT * FROM tblCars")
Now here's the rub: I can then access the fields of the recordset
as
year = rstCars!fYear
AB has syntax that allows me to make such a construction at compile-time
that will yield a dynamic result at run-time.
So my basic question is, is there any mechanism in C++ to do a similar
thing?
The closest I can come is to define a recordset object that has a member
function
void * Fields(char* fName);
so that I can say
int year;
recordset rstCars("SELECT * FROM tblCars");
year = rstCars.Fields("fYear");
Is this a reasonable way to do this? Is there any mechanism in C++ to
do it more elegantly?
--
% Randy Yates % "Watching all the days go by...
%% Fuquay-Varina, NC % Who are you and who am I?"
%%% 919-577-9882 % 'Mission (A World Record)',
%%%% <[email protected]> % *A New World Record*, ELO
http://home.earthlink.net/~yatescr