Error in open() function in CDaoDatabase class of MFC-> Unhandled exception in myProject.exe(DAO360.DLL):0xc0000005:Access
-
Hi! I m working on a database project in which i use CDaoDatabase class of MFC to create the connection with a Access .mdb file by using its open() function. and then use CDaoQueryDef class to save the query in the database. It works well when I run my program first time for a database but if I select the another or same Access .mdb file without closing the exe of my project it give error in its open function. the error msg is somthing like this-> Unhandled exception in myProject.exe(DAO360.DLL):0xc0000005:Access violation. Pls help me to solve this problem as early as possible. Ansh
-
Hi! I m working on a database project in which i use CDaoDatabase class of MFC to create the connection with a Access .mdb file by using its open() function. and then use CDaoQueryDef class to save the query in the database. It works well when I run my program first time for a database but if I select the another or same Access .mdb file without closing the exe of my project it give error in its open function. the error msg is somthing like this-> Unhandled exception in myProject.exe(DAO360.DLL):0xc0000005:Access violation. Pls help me to solve this problem as early as possible. Ansh
Maybe try wrapping methods that can throw exceptions in try/catch blocks. Then you can get detailed error info. try { ...try database open } catch (CDaoException *e) { ... examine exception/error info here e->Delete(); }
*EDIT* Besides checking for exceptions - are the string pointers you pass to Open() valid? (Thanks Steve!)
Mark -- modified at 1:41 Friday 6th July, 2007Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."
-
Maybe try wrapping methods that can throw exceptions in try/catch blocks. Then you can get detailed error info. try { ...try database open } catch (CDaoException *e) { ... examine exception/error info here e->Delete(); }
*EDIT* Besides checking for exceptions - are the string pointers you pass to Open() valid? (Thanks Steve!)
Mark -- modified at 1:41 Friday 6th July, 2007Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."
It looks like the exception was an access violation and so your code will not catch it.
Steve
-
It looks like the exception was an access violation and so your code will not catch it.
Steve
:doh: Thanks :)
Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."
-
Maybe try wrapping methods that can throw exceptions in try/catch blocks. Then you can get detailed error info. try { ...try database open } catch (CDaoException *e) { ... examine exception/error info here e->Delete(); }
*EDIT* Besides checking for exceptions - are the string pointers you pass to Open() valid? (Thanks Steve!)
Mark -- modified at 1:41 Friday 6th July, 2007Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."
i use try wrapping method bt it unale to track the error. Acctually wn i debug my program and track all steps then i watch that wn the open function of CDaoDatabase class is called like this-> void CDaoDatabase::Open(LPCTSTR lpszName, BOOL bExclusive, BOOL bReadOnly, LPCTSTR lpszConnect) { ---- ---- DAO_CHECK(m_pWorkspace->m_pDAOWorkspace->OpenDatabase( V_BSTR(&var), COleVariant((long)bExclusive, VT_BOOL), COleVariant((long)bReadOnly, VT_BOOL), COleVariant(lpszConnect, VT_BSTRT), &m_pDAODatabase)); } and wn the function DAO_CHECK is called it through the exceptions. Ansh
-
i use try wrapping method bt it unale to track the error. Acctually wn i debug my program and track all steps then i watch that wn the open function of CDaoDatabase class is called like this-> void CDaoDatabase::Open(LPCTSTR lpszName, BOOL bExclusive, BOOL bReadOnly, LPCTSTR lpszConnect) { ---- ---- DAO_CHECK(m_pWorkspace->m_pDAOWorkspace->OpenDatabase( V_BSTR(&var), COleVariant((long)bExclusive, VT_BOOL), COleVariant((long)bReadOnly, VT_BOOL), COleVariant(lpszConnect, VT_BSTRT), &m_pDAODatabase)); } and wn the function DAO_CHECK is called it through the exceptions. Ansh
What are the values and contents of lpszName and lpszConnect? Mark
This episode brought to you by the number 5
-
What are the values and contents of lpszName and lpszConnect? Mark
This episode brought to you by the number 5
-
aaaan wrote:
and the lpszConnect stores 0
I'm not sure a NULL pointer is allowed there. Instead of 0, try passing _T("") Mark
This episode brought to you by the number 5