Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error in open() function in CDaoDatabase class of MFC-> Unhandled exception in myProject.exe(DAO360.DLL):0xc0000005:Access

Error in open() function in CDaoDatabase class of MFC-> Unhandled exception in myProject.exe(DAO360.DLL):0xc0000005:Access

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasec++
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aaaan
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • A aaaan

      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

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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, 2007

      Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

      S A 2 Replies Last reply
      0
      • M Mark Salsbery

        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, 2007

        Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        It looks like the exception was an access violation and so your code will not catch it.

        Steve

        M 1 Reply Last reply
        0
        • S Stephen Hewitt

          It looks like the exception was an access violation and so your code will not catch it.

          Steve

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          :doh: Thanks :)

          Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

          1 Reply Last reply
          0
          • M Mark Salsbery

            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, 2007

            Mark Salsbery Microsoft MVP - Visual C++ "Go that way, really fast. If something gets in your way, turn."

            A Offline
            A Offline
            aaaan
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • A aaaan

              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

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              What are the values and contents of lpszName and lpszConnect? Mark

              This episode brought to you by the number 5

              A 1 Reply Last reply
              0
              • M Mark Salsbery

                What are the values and contents of lpszName and lpszConnect? Mark

                This episode brought to you by the number 5

                A Offline
                A Offline
                aaaan
                wrote on last edited by
                #7

                lpszName the path of the mdb file is displayed and the lpszConnect stores 0. Ansh

                M 1 Reply Last reply
                0
                • A aaaan

                  lpszName the path of the mdb file is displayed and the lpszConnect stores 0. Ansh

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups