Create data base in Access 2003 and try to connect it in my programm using DAO Open("path"). After compiling getting error message "Unrecognized database format db1.mdb".
But if i create a data base in program with help of DAO Create, everiting is working.
But problem is that i have to work with the base created in Access 2003.
Please somebody help.
Using VC++ 6.

Upgrade to VC++ 2008 or use an earlier version of Access. VC++ 6.0 is no longer supported by Microsoft, and hasn't been for several years now.

But VC++ 6 is the environment my University works with.
I heard i can add AfxGetModuleState()->m_dwVersion = 0x0601 in BOOL CMyApp::InitInstance, but got an error m_dwVersion is not a member of AFX_MODULE_STATE.
Maybe there is a way to fix it?

Ok, I get Access Data Base from VC++ 6. Now I try to get field values date and float numder, but don't know how to do that.
To get integer i do it like that:
CDaoRecordset cr;
COleVariant val;
cr.GetFieldValue("Age", val);
long d = val.lVal;
CString str;
str.Format("%d", d);

But i don't know how to get date and float from the database.
I have float like 0,0433 and date like 01.01.2008
Please help.

COleVariant class encapsulates the VARIANT structure, which is nothing more than a union of a bunch of data types and pointers. The field vt is an integer that tells which of the field is represented by the union. Those data types are listed at the bottom of this page.

So to extract a float

COleVariant val;
float fl;
if( val.vt == VT_R4)
    fl = val.fltVal;

// similarily a string
CString str;
if(val.vt == VT_BSTR)
   str = val.bstrVal;

I know this is ridiculous but i did like you showed me

COleVariant val;
float fl;
if( val.vt == VT_R4)
fl = val.fltVal;

and instead of getting number 0,0433 i got something like -1538876.
and instead of the date i got 0 from my Access DataBase.

I've checked types of variables everything is correct.
Maybe i missed smth else?

Hi again,
Try to insert into my database date using DateTimePicker and get this error DDX_FieldDateTimeCtrl undeclared identifier. Is there way to fix it?
Still use VC++ 6.

This article has been dead for over six months. Start a new discussion instead.