MRM
MRM

Reputation: 571

open a .mdb database with a visual studio 6 program

I try openning a .mdb file using CDaoDatabase, but at Open() catches an error: Unrecognised database format. I created the database first in MSAcces2007 and saved the file as .mdb, then i installed MSAcces2003 and created the file again, but there's the same error. Does anyone have a clue what's happening?

CString pathDB = "SMACDB\\Transports.mdb";
CDaoDatabase dbTransp;

try
{
    dbTransp.Open(pathDB);

    CDaoRecordset rs(&dbTransp);
    COleVariant var1;
    rs.Open(dbOpenSnapshot, "SELECT * FROM Transporturi");
    while (!rs.IsEOF())
    {
        var1 = rs.GetFieldValue(1);
        CString val = (LPCTSTR)var1.bstrVal;
        g_carRestrict.pCarNmb.AddTail(val);
        var1 = rs.GetFieldValue(2);
        g_carRestrict.pAllowed.AddTail(var1.lVal);

        rs.MoveNext();
    }

    rs.Close();
    dbTransp.Close();
}
catch (CDaoException *pEx)
{
    pEx->Delete();
}

Upvotes: 0

Views: 1324

Answers (1)

Sheng Jiang 蒋晟
Sheng Jiang 蒋晟

Reputation: 15261

Visual C++ 6 uses DAO 3.5 by default which does not support Access 2000 or later formats. To have MFC uses DAO 3.6, change the runtime version number to 6.01.

Suggested reading:

You receive an "Unrecognized database format" error message when you open a database created with Access 2000

Upvotes: 2

Related Questions