Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDaoDatabase and DSN

Status
Not open for further replies.

dcusick

Technical User
Aug 9, 2000
271
US
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.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top