What's up everyone? I'm having a heck of a problem trying to connect to a MSAccess 97 DB via a DSN using DAO. Nothing I do will allow me to connect. If I try to open the database using the name, mdw, user, and pass, it works fine. I am able to open it no problem.
That code above works fine. However, I am creating a DLL for this. THe caller program does not have the name/mdw/user/pass, it just has the DSN. So I need to be able to open this DB by using the DSN. This is what I found...
However, this never seems to work, and always throws an exception. Anyone have any ideas??? Thanks in advance.
Doug
Code:
AfxDaoInit();
DAODBEngine* pDBEngine = AfxDaoGetEngine();
ASSERT (pDBEngine != NULL);
CDaoDatabase cdb;
CDaoWorkspace myWS;
DAO_CHECK( pDBEngine->put_SystemDB( varSystemDB.bstrVal ) );
myWS.Create("New",mdwUser, mdwPass);
myWS.Append();
cdb.m_pWorkspace = &myWS;
cdb.Open(dbName);
That code above works fine. However, I am creating a DLL for this. THe caller program does not have the name/mdw/user/pass, it just has the DSN. So I need to be able to open this DB by using the DSN. This is what I found...
Code:
CDaoDatabase cdb;
cdb.Open(NULL,FALSE,FALSE,_T("ODBC;DSN=dsnName;UID=user;PWD=pass;"));
However, this never seems to work, and always throws an exception. Anyone have any ideas??? Thanks in advance.
Doug