Database to C++
-
hey, noob here I'm reading some database queries into a structure in C++ The database class I'm using MFC CDatabase/CRecordset reads all the data as type strings. So my questions are: What is the best practice for storing the fields? should I convert them to their appropriate data type as I read them from the data base,(using CODBCFieldInfo) to determine the datatype? or is their a class that exists that already does converts the query to a structure automatically in C++? what is the preferred method for handling datatypes for ma database?
-
hey, noob here I'm reading some database queries into a structure in C++ The database class I'm using MFC CDatabase/CRecordset reads all the data as type strings. So my questions are: What is the best practice for storing the fields? should I convert them to their appropriate data type as I read them from the data base,(using CODBCFieldInfo) to determine the datatype? or is their a class that exists that already does converts the query to a structure automatically in C++? what is the preferred method for handling datatypes for ma database?
You may use the
CRecordset
member function GetFieldValue()[^]. There are different overloaded versions of this function which retrieve the values as strings or variants. Use a function which retrieves a variant to get values as C types that correspond to the type stored in the database.